summaryrefslogtreecommitdiff
path: root/libs/binder/Status.cpp
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2022-06-10 19:50:43 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2022-06-10 19:50:43 +0000
commit4590ce6a83b7f012dba3679e5eb124411c71d6e1 (patch)
treea81db81499df99de9edbe9aa2bc8fe7f7dbd2007 /libs/binder/Status.cpp
parent007b4fa62cea814721f70931cb3d8ce9cab9e9bd (diff)
parent83562e55fb1998bb170a90a591fbe6228eb02756 (diff)
Merge "libbinder: Status - fix read at end of Parcel" am: c25cfc6c8f am: 83562e55fb
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2117835 Change-Id: Ic323fe358877ea144f9f30be01e442282263b8fe Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'libs/binder/Status.cpp')
-rw-r--r--libs/binder/Status.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/libs/binder/Status.cpp b/libs/binder/Status.cpp
index 83b97d04c6..dba65878fb 100644
--- a/libs/binder/Status.cpp
+++ b/libs/binder/Status.cpp
@@ -139,6 +139,9 @@ status_t Status::readFromParcel(const Parcel& parcel) {
mMessage = String8(message.value_or(String16()));
// Skip over the remote stack trace data
+ const size_t remote_start = parcel.dataPosition();
+ // Get available size before reading more
+ const size_t remote_avail = parcel.dataAvail();
int32_t remote_stack_trace_header_size;
status = parcel.readInt32(&remote_stack_trace_header_size);
if (status != OK) {
@@ -146,13 +149,16 @@ status_t Status::readFromParcel(const Parcel& parcel) {
return status;
}
if (remote_stack_trace_header_size < 0 ||
- static_cast<size_t>(remote_stack_trace_header_size) > parcel.dataAvail()) {
+ static_cast<size_t>(remote_stack_trace_header_size) > remote_avail) {
android_errorWriteLog(0x534e4554, "132650049");
setFromStatusT(UNKNOWN_ERROR);
return UNKNOWN_ERROR;
}
- parcel.setDataPosition(parcel.dataPosition() + remote_stack_trace_header_size);
+
+ if (remote_stack_trace_header_size != 0) {
+ parcel.setDataPosition(remote_start + remote_stack_trace_header_size);
+ }
if (mException == EX_SERVICE_SPECIFIC) {
status = parcel.readInt32(&mErrorCode);