summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2016-11-03 13:32:41 -0700
committerBrinly Taylor <brinly@brinly.me>2017-03-13 04:55:32 +0000
commit0ff545d4a7ab8ceb76a0e90c11cf83adebe8b140 (patch)
treed86f7b5768df2b0bc903fb2df36a131ce268b132
parent78f9ca0f1fe32f2d25017ca35d3b2d5f20bba177 (diff)
downloadframeworks_native-0ff545d4a7ab8ceb76a0e90c11cf83adebe8b140.zip
frameworks_native-0ff545d4a7ab8ceb76a0e90c11cf83adebe8b140.tar.gz
frameworks_native-0ff545d4a7ab8ceb76a0e90c11cf83adebe8b140.tar.bz2
Correct overflow check in Parcel resize code
Fix merge conflict into nyc-mr1-release Bug 31929765 Change-Id: Ie27b9945f1de056624668869bdf9a5578abff467 (cherry picked from commit 65dd433f0db2fe402dc725f7012c6e26769b3224) (cherry picked from commit b4d6b292bce7d82c93fd454078dedf5a1302b9fa)
-rw-r--r--libs/binder/Parcel.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 65e67d6..4690a82 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -553,7 +553,7 @@ status_t Parcel::appendFrom(const Parcel *parcel, size_t offset, size_t len)
// grow objects
if (mObjectsCapacity < mObjectsSize + numObjects) {
size_t newSize = ((mObjectsSize + numObjects)*3)/2;
- if (newSize < mObjectsSize) return NO_MEMORY; // overflow
+ if (newSize*sizeof(binder_size_t) < mObjectsSize) return NO_MEMORY; // overflow
binder_size_t *objects =
(binder_size_t*)realloc(mObjects, newSize*sizeof(binder_size_t));
if (objects == (binder_size_t*)0) {
@@ -1113,7 +1113,7 @@ restart_write:
}
if (!enoughObjects) {
size_t newSize = ((mObjectsSize+2)*3)/2;
- if (newSize < mObjectsSize) return NO_MEMORY; // overflow
+ if (newSize*sizeof(binder_size_t) < mObjectsSize) return NO_MEMORY; // overflow
binder_size_t* objects = (binder_size_t*)realloc(mObjects, newSize*sizeof(binder_size_t));
if (objects == NULL) return NO_MEMORY;
mObjects = objects;