diff options
| author | 2021-01-08 01:09:19 +0000 | |
|---|---|---|
| committer | 2021-01-08 01:09:19 +0000 | |
| commit | 596a4ea492eda8e7f12a24aeab6a6e9abf2843d0 (patch) | |
| tree | 4ae88e06c78b9c5bde7af38855e8af003dcd40ff | |
| parent | a942834c31ce36e78097185e8ec453f12ca43097 (diff) | |
| parent | 18b36460b0608c2e2f35472d4d75c95d2c31437c (diff) | |
Merge "Prevent skipBytes from infinitely looping"
| -rw-r--r-- | media/java/android/media/ExifInterface.java | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/media/java/android/media/ExifInterface.java b/media/java/android/media/ExifInterface.java index 8ea380a9f3b7..21f8623b1953 100644 --- a/media/java/android/media/ExifInterface.java +++ b/media/java/android/media/ExifInterface.java @@ -5019,13 +5019,18 @@ public class ExifInterface { @Override public int skipBytes(int byteCount) throws IOException { - int totalSkip = Math.min(byteCount, mLength - mPosition); - int skipped = 0; - while (skipped < totalSkip) { - skipped += mDataInputStream.skipBytes(totalSkip - skipped); + int totalBytesToSkip = Math.min(byteCount, mLength - mPosition); + int totalSkipped = 0; + while (totalSkipped < totalBytesToSkip) { + int skipped = mDataInputStream.skipBytes(totalBytesToSkip - totalSkipped); + if (skipped > 0) { + totalSkipped += skipped; + } else { + break; + } } - mPosition += skipped; - return skipped; + mPosition += totalSkipped; + return totalSkipped; } public int readUnsignedShort() throws IOException { |