diff options
| author | 2021-12-23 14:39:57 +0900 | |
|---|---|---|
| committer | 2021-12-24 08:54:31 +0900 | |
| commit | d23f9500efa59d46c57db423a630b111e889a680 (patch) | |
| tree | ca24b8b72a0b211dbca226a18693ea93b26952e0 /libs/binder/Parcel.cpp | |
| parent | a98ef807a612f81cf75dd4c83ba09e00d2df6ebf (diff) | |
libbinder: added enforceNoDataAvail()
enforceNoDataAvail() verifies that there's no bytes left to be read on
the Parcel.
Bug: 208509444
Test: atest binderUnitTest
Test: binder_parcel_fuzzer
Change-Id: I469c8778fa54f3db27f00a9df8db668a0c4c76bc
Diffstat (limited to 'libs/binder/Parcel.cpp')
| -rw-r--r-- | libs/binder/Parcel.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index 7027a4b0a3..6fb189cd70 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -739,6 +739,17 @@ bool Parcel::enforceInterface(const char16_t* interface, } } +binder::Status Parcel::enforceNoDataAvail() const { + const auto n = dataAvail(); + if (n == 0) { + return binder::Status::ok(); + } + return binder::Status:: + fromExceptionCode(binder::Status::Exception::EX_BAD_PARCELABLE, + String8::format("Parcel data not fully consumed, unread size: %zu", + n)); +} + size_t Parcel::objectsCount() const { return mObjectsSize; |