diff options
author | Michael Lentine <mlentine@google.com> | 2014-12-02 11:15:56 -0800 |
---|---|---|
committer | Michael Lentine <mlentine@google.com> | 2014-12-02 11:15:56 -0800 |
commit | 784fd39a19f659e3b464bd9a78361c0adc1cdcab (patch) | |
tree | 694d137ce7c7148182a9c418776afaf89fefce6a | |
parent | afe2b1fadd29149ceed639357e44e06e97c3a5ca (diff) | |
parent | d6308379d9ddf946f5ce60fa2d0b809fa1238a63 (diff) | |
download | frameworks_native-784fd39a19f659e3b464bd9a78361c0adc1cdcab.zip frameworks_native-784fd39a19f659e3b464bd9a78361c0adc1cdcab.tar.gz frameworks_native-784fd39a19f659e3b464bd9a78361c0adc1cdcab.tar.bz2 |
resolved conflicts for merge of d6308379 to lmp-dev
Change-Id: I92ed61b6fdfe458cf5f8bfd6f0b37ff736280500
-rw-r--r-- | libs/ui/GraphicBuffer.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp index 9b0bd60..e768f13 100644 --- a/libs/ui/GraphicBuffer.cpp +++ b/libs/ui/GraphicBuffer.cpp @@ -310,10 +310,19 @@ status_t GraphicBuffer::unflatten( const size_t numFds = buf[8]; const size_t numInts = buf[9]; + const size_t maxNumber = UINT_MAX / sizeof(int); + if (numFds >= maxNumber || numInts >= (maxNumber - 10)) { + width = height = stride = format = usage = 0; + handle = NULL; + ALOGE("unflatten: numFds or numInts is too large: %d, %d", + numFds, numInts); + return BAD_VALUE; + } + const size_t sizeNeeded = (10 + numInts) * sizeof(int); if (size < sizeNeeded) return NO_MEMORY; - size_t fdCountNeeded = 0; + size_t fdCountNeeded = numFds; if (count < fdCountNeeded) return NO_MEMORY; if (handle) { @@ -328,6 +337,12 @@ status_t GraphicBuffer::unflatten( format = buf[4]; usage = buf[5]; native_handle* h = native_handle_create(numFds, numInts); + if (!h) { + width = height = stride = format = usage = 0; + handle = NULL; + ALOGE("unflatten: native_handle_create failed"); + return NO_MEMORY; + } memcpy(h->data, fds, numFds*sizeof(int)); memcpy(h->data + numFds, &buf[10], numInts*sizeof(int)); handle = h; |