Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1d23ac9a authored by Zhen Zhang's avatar Zhen Zhang Committed by Nishith Khanna
Browse files

RESTRICT AUTOMERGE: Validate the position value for UsageEvent

Ensure the position value getting from a Parcel for UsageEvent
is smaller than that parcel's data size before setting it.

Bug: 399155883
Ignore-AOSP-First: security fix
Test: atest FrameworksCoreTests:android.app.usage.*
Test: atest CtsUsageStatsTestCases:android.app.usage.cts.UsageStatsTest
Flag: EXEMPT bug fix
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:838301ebf546fbfdcf154797890cd2c1d2017553
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:a75397155667ba8a178f1f8ea837e7e6123eadf9
Merged-In: I32605b73a2ded91c1bf392d5f8d830ff765a3f23
Change-Id: I32605b73a2ded91c1bf392d5f8d830ff765a3f23
parent e541127e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -857,6 +857,11 @@ public final class UsageEvents implements Parcelable {
            mParcel.setDataPosition(0);
            mParcel.appendFrom(data, data.dataPosition(), listByteLength);
            mParcel.setDataSize(mParcel.dataPosition());
            if (positionInParcel > mParcel.dataSize()) {
                throw new IllegalArgumentException(
                        "Obtained an invalid position value(" + positionInParcel
                        + ") from Parcel.");
            }
            mParcel.setDataPosition(positionInParcel);
        }
    }