summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2015-05-12 17:35:48 -0700
committerAbhisek Devkota <ciwrl@cyanogenmod.com>2015-08-12 14:22:05 -0700
commitea184596cc9299fae0863b4b99465be3f2a21c30 (patch)
tree09f0b699d5b97628ea64a6f0486be1e686dd41e4
parent4f2f38f1370856c482c64b4fe5f5ec809794af94 (diff)
downloadandroid_frameworks_native-stable/cm-12.0-YNG4N.tar.gz
android_frameworks_native-stable/cm-12.0-YNG4N.tar.bz2
android_frameworks_native-stable/cm-12.0-YNG4N.zip
Verify that the native handle was createdstable/cm-12.0-YNG4N
The inputs to native_handle_create can cause an overflowed allocation, so check the return value of native_handle_create before accessing the memory it returns. CYNGNOS-446 Bug:19334482 Change-Id: I1f489382776c2a1390793a79dc27ea17baa9b2a2 (cherry picked from commit eaac99a7172da52a76ba48c26413778a74951b1a) (cherry picked from commit 7d7593f1e45804278819f06a589e4777e3780fd3)
-rw-r--r--libs/binder/Parcel.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 1dbb06fef..777bc3c77 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -1217,6 +1217,10 @@ native_handle* Parcel::readNativeHandle() const
if (err != NO_ERROR) return 0;
native_handle* h = native_handle_create(numFds, numInts);
+ if (!h) {
+ return 0;
+ }
+
for (int i=0 ; err==NO_ERROR && i<numFds ; i++) {
h->data[i] = dup(readFileDescriptor());
if (h->data[i] < 0) err = BAD_VALUE;