Skip to content

Commit 229be7d

Browse files
Michael Lentineandi34
authored andcommitted
Update maxNumber to be smaller.
There shouldn't be more than 4096 fds (probably signficantly smaller) and there shouldn't be more than 4096 ints. Bug: 18076253 Change-Id: I3a3e50ee3078a4710e9737114e65afc923ed0573
1 parent 69cb285 commit 229be7d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libs/ui/GraphicBuffer.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,11 @@ status_t GraphicBuffer::unflatten(
251251
const size_t numFds = buf[6];
252252
const size_t numInts = buf[7];
253253

254-
const size_t maxNumber = UINT_MAX / sizeof(int);
254+
// Limit the maxNumber to be relatively small. The number of fds or ints
255+
// should not come close to this number, and the number itself was simply
256+
// chosen to be high enough to not cause issues and low enough to prevent
257+
// overflow problems.
258+
const size_t maxNumber = 4096;
255259
if (numFds >= maxNumber || numInts >= (maxNumber - 8)) {
256260
width = height = stride = format = usage = 0;
257261
handle = NULL;

0 commit comments

Comments
 (0)