diff options
| author | 2024-10-31 02:22:52 +0000 | |
|---|---|---|
| committer | 2024-10-31 02:22:52 +0000 | |
| commit | fb27f09ae7b7d6f634bd7f43f5fb5ab9981ce078 (patch) | |
| tree | 790dff4e5721b1d6297613fc40d61b74e96433f7 | |
| parent | 7fe9e798d908d884c86d40980b819e9fc15a4ad8 (diff) | |
| parent | fde1dbbfac5ed506593bcdabe9ce5644fd29c0f1 (diff) | |
Merge "libbinder: Parcel: validate read data before write" into tm-dev am: fde1dbbfac
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/30026349
Change-Id: I50a1109ea468e66ccc657014a22f83914b2f16e5
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 0264b1cfad..acf262aa4a 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -888,6 +888,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 @@ -1405,6 +1409,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 @@ -1621,6 +1629,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; + } + memcpy(mData + mDataPos, &val, sizeof(val)); return finishWrite(sizeof(val)); } |