summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2016-11-03 13:32:41 -0700
committergitbuildkicker <android-build@google.com>2017-01-04 10:37:14 -0800
commit541b1ebe0955ef40693b0746be2cd4f527feb7c2 (patch)
tree2b63da15310105f86dbaf79f95b89b21de1d9aa1
parent74dae3378a4dfa885118f0ff5c807b42f3f9fb28 (diff)
downloadandroid-frameworks-native-541b1ebe0955ef40693b0746be2cd4f527feb7c2.tar.gz
android-frameworks-native-541b1ebe0955ef40693b0746be2cd4f527feb7c2.tar.xz
Correct overflow check in Parcel resize codeandroid-7.1.1_r28android-7.1.1_r17m/android-7.1.1_r28
Fix merge conflict into nyc-mr1-security-a-release Bug 31929765 Change-Id: Ie27b9945f1de056624668869bdf9a5578abff467 (cherry picked from commit 65dd433f0db2fe402dc725f7012c6e26769b3224) (cherry picked from commit 54d46f2f381c3350363479380fadcda925412b51)
-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 e88ae29..19ce3eb 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -548,7 +548,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) {
@@ -1342,7 +1342,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;