diff options
| author | 2024-11-01 17:42:50 +0000 | |
|---|---|---|
| committer | 2024-11-01 17:42:50 +0000 | |
| commit | 03fd6d4e3efe38221ae84d893fb0e57c097f86c2 (patch) | |
| tree | 511fe20c8d5b066bfccf9fa71a44e4475197d2c5 | |
| parent | 145061195606be065b15829161ccebe14c866c98 (diff) | |
| parent | f0d7060bc7b063261835a8a7419d6c36086618ec (diff) | |
Merge "libbinder: Parcel: validate read data before write" into sc-dev am: 538e27fa95 am: f0d7060bc7
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/30026350
Change-Id: I256a524288cb7f615fd85fd2bb74435ce8a61180
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | libs/binder/Parcel.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index 4d0eb48942..9c5466635e 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -796,6 +796,10 @@ restart_write: //printf("Writing %ld bytes, padded to %ld\n", len, padded); uint8_t* const data = mData+mDataPos; + if (status_t status = validateReadData(mDataPos + padded); status != OK) { + return nullptr; // drops status + } + // Need to pad at end? if (padded != len) { #if BYTE_ORDER == BIG_ENDIAN @@ -1313,6 +1317,10 @@ status_t Parcel::writeObject(const flat_binder_object& val, bool nullMetaData) const bool enoughObjects = mObjectsSize < mObjectsCapacity; if (enoughData && enoughObjects) { restart_write: + if (status_t status = validateReadData(mDataPos + sizeof(val)); status != OK) { + return status; + } + *reinterpret_cast<flat_binder_object*>(mData+mDataPos) = val; // remember if it's a file descriptor @@ -1505,6 +1513,10 @@ status_t Parcel::writeAligned(T val) { if ((mDataPos+sizeof(val)) <= mDataCapacity) { restart_write: + if (status_t status = validateReadData(mDataPos + sizeof(val)); status != OK) { + return status; + } + *reinterpret_cast<T*>(mData+mDataPos) = val; return finishWrite(sizeof(val)); } |