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

Commit 18b36460 authored by Jin Seok Park's avatar Jin Seok Park
Browse files

Prevent skipBytes from infinitely looping

Skipping bytes on a stream may return 0 forever (e.g. network
stream is disconnected), so need to break out of while loop if that
happens.

Bug: 175808980
Test: N/A (difficult to reproduce this case)
Change-Id: Ic6ed131cc4bbff3c01d7d577e8fc1d6d5804c598
parent f57116d8
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -4997,13 +4997,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 {