From 06041db074add181ddf19c3e4235a73c62207495 Mon Sep 17 00:00:00 2001 From: Michael Wachenschwanz Date: Wed, 15 May 2019 22:58:15 -0700 Subject: [PATCH] Clear the Parcel before writing an exception during a transaction This prevents any object data from being accidentally overwritten by the exception, which could cause unexpected malformed objects to be sent across the transaction. Test: atest CtsOsTestCases:ParcelTest#testExceptionOverwritesObject Fixes: 34175893 Change-Id: Iaf80a0ad711762992b8ae60f76d861c97a403013 --- core/java/android/os/Binder.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java index 66ddf21790fe..6178b2bf5817 100644 --- a/core/java/android/os/Binder.java +++ b/core/java/android/os/Binder.java @@ -1033,6 +1033,8 @@ public class Binder implements IBinder { Log.w(TAG, "Caught a RuntimeException from the binder stub implementation.", e); } } else { + // Clear the parcel before writing the exception + reply.setDataSize(0); reply.setDataPosition(0); reply.writeException(e); } -- 2.11.0