From: Martijn Coenen Date: Wed, 4 Apr 2018 09:46:56 +0000 (+0200) Subject: Don't pad before calling writeInPlace(). X-Git-Tag: android-x86-8.1-r1~2^2^2 X-Git-Url: http://git.osdn.net/view?p=android-x86%2Fframeworks-native.git;a=commitdiff_plain;h=51db8c36586507ef80c3f4e76358f58a7b7fcdb7 Don't pad before calling writeInPlace(). writeInplace() itself already pads securely, by masking off the padded bytes. If the padding is done before calling writeInplace(), no mask is applied, and heap data can leak. Bug: 77237570 Test: builds Change-Id: Ide27a0002d4ed4196530430760245b971f6a3f44 Merged-In: Ide27a0002d4ed4196530430760245b971f6a3f44 (cherry picked from commit f8542381b72a7bb2452a5278a00ca8c34edbf8a0) (cherry picked from commit 732132b765cd7b667f16cf32f0fe4c852d7d44dd) Change-Id: Ia9d0e50488ee1f427c182b6277f877d4eda76f77 --- diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index 3fafbb8d1b..460bbe2fc5 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -1277,7 +1277,7 @@ status_t Parcel::write(const FlattenableHelperInterface& val) if (err) return err; // payload - void* const buf = this->writeInplace(pad_size(len)); + void* const buf = this->writeInplace(len); if (buf == NULL) return BAD_VALUE;