commit | 428f4999302b8144335fcd9e471099095f438e58 | [log] [tgz] |
---|---|---|
author | Yi-Yo Chiang <yochiang@google.com> | Mon Feb 21 21:07:22 2022 +0800 |
committer | Yi-Yo Chiang <yochiang@google.com> | Mon Feb 21 21:07:22 2022 +0800 |
tree | faffe01982f73b28b581243dd463640f60bdf14c | |
parent | 66660a1a4e8e759af608fffd3f768c69e9546e0a [diff] |
Fix unwanted sign-extention when converting byte -> int byte(255) converts to int(-1). This is not what we want, we want int(255), in other words unsigned conversion. This bug is causing premature EOF when read() is called, because when a byte(255) is returned, it gets sign-extend to int(-1), causing the caller to think EOF is reached. Bug: 217427392 Test: Presubmit Change-Id: I8ee864816c77cfe2900f5e300d7d4411cce6753a
diff --git a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/SparseInputStream.java b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/SparseInputStream.java index 72230b4..4117d0f 100644 --- a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/SparseInputStream.java +++ b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/SparseInputStream.java
@@ -177,7 +177,7 @@ ret = 0; break; case SparseChunk.FILL: - ret = mCur.fill[(4 - ((int) mLeft & 0x3)) & 0x3]; + ret = Byte.toUnsignedInt(mCur.fill[(4 - ((int) mLeft & 0x3)) & 0x3]); break; default: throw new IOException("Unsupported Chunk:" + mCur.toString());