Update Parcel readLazyValue to ignore negative object lengths
Addresses a security vulnerability where a (-8) length object would cause dataPosition to be reset back to the statt of the value, and be re-read again. Bug: 240138294 Test: atest ParcelTest BundleTest AmbiguousBundlesTest Test: manually ran PoC Change-Id: I1ab1df6f2a802d8cdf02c89c12959b09d7b1a5c4 Merged-In: I1ab1df6f2a802d8cdf02c89c12959b09d7b1a5c4
This commit is contained in:
@@ -4388,6 +4388,9 @@ public final class Parcel {
|
|||||||
int type = readInt();
|
int type = readInt();
|
||||||
if (isLengthPrefixed(type)) {
|
if (isLengthPrefixed(type)) {
|
||||||
int objectLength = readInt();
|
int objectLength = readInt();
|
||||||
|
if (objectLength < 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
int end = MathUtils.addOrThrow(dataPosition(), objectLength);
|
int end = MathUtils.addOrThrow(dataPosition(), objectLength);
|
||||||
int valueLength = end - start;
|
int valueLength = end - start;
|
||||||
setDataPosition(end);
|
setDataPosition(end);
|
||||||
|
|||||||
Reference in New Issue
Block a user