diff options
author | 2025-03-20 20:37:51 -0700 | |
---|---|---|
committer | 2025-03-20 20:37:51 -0700 | |
commit | f9bfbe16e4399252bdc51060e5c8af82db6f470e (patch) | |
tree | 9281c01d08d0e4dd43091d958a310b4a3c0f0792 | |
parent | 5c398853aefb07d6ced3b98ac34b786b5558be84 (diff) | |
parent | 611b730bade54a0a79dbcc3087d9393086e6dbdf (diff) |
Merge "Check mDataPos to see if the Parcel needs to grow" into main
-rw-r--r-- | libs/binder/Parcel.cpp | 2 | ||||
-rw-r--r-- | libs/binder/tests/binderParcelUnitTest.cpp | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index 777c22a63e..2c37624304 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -542,7 +542,7 @@ status_t Parcel::appendFrom(const Parcel* parcel, size_t offset, size_t len) { return BAD_VALUE; } - if ((mDataSize+len) > mDataCapacity) { + if ((mDataPos + len) > mDataCapacity) { // grow data err = growData(len); if (err != NO_ERROR) { diff --git a/libs/binder/tests/binderParcelUnitTest.cpp b/libs/binder/tests/binderParcelUnitTest.cpp index 6259d9d2d2..a71da3f384 100644 --- a/libs/binder/tests/binderParcelUnitTest.cpp +++ b/libs/binder/tests/binderParcelUnitTest.cpp @@ -197,6 +197,17 @@ TEST(Parcel, AppendPlainDataPartial) { ASSERT_EQ(2, p2.readInt32()); } +TEST(Parcel, AppendWithBadDataPos) { + Parcel p1; + p1.writeInt32(1); + p1.writeInt32(1); + Parcel p2; + p2.setDataCapacity(8); + p2.setDataPosition(10000); + + EXPECT_EQ(android::BAD_VALUE, p2.appendFrom(&p1, 0, 8)); +} + TEST(Parcel, HasBinders) { sp<IBinder> b1 = sp<BBinder>::make(); |