diff options
| author | 2016-05-09 21:11:03 +0000 | |
|---|---|---|
| committer | 2016-05-09 21:11:03 +0000 | |
| commit | 56dea28189ff0894d24ebb63650ad5159031549c (patch) | |
| tree | ad82efd65753f26ed5fd76699d729adc7166cd20 | |
| parent | b38df7b4e9d93686c62d9ec654bba3be6e561d56 (diff) | |
| parent | c2c470c700a4e0fbbcd5b99da144f02cee7b9b3e (diff) | |
Correctly handle dup() failure in Parcel::readNativeHandle am: 1de7966c72 am: 275c9f60f9 am: 853702ce3d am: 775f2e6dbf am: 82afbe2258
am: c2c470c700
* commit 'c2c470c700a4e0fbbcd5b99da144f02cee7b9b3e':
Correctly handle dup() failure in Parcel::readNativeHandle
Change-Id: I68084d5f6bfd4b209c738b94a0f31fe9db113d9f
| -rw-r--r-- | libs/binder/Parcel.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index d769caa7ea..5a7db3f18a 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -1236,7 +1236,13 @@ native_handle* Parcel::readNativeHandle() const for (int i=0 ; err==NO_ERROR && i<numFds ; i++) { h->data[i] = dup(readFileDescriptor()); - if (h->data[i] < 0) err = BAD_VALUE; + if (h->data[i] < 0) { + for (int j = 0; j < i; j++) { + close(h->data[j]); + } + native_handle_delete(h); + return 0; + } } err = read(h->data + numFds, sizeof(int)*numInts); if (err != NO_ERROR) { |