Skip to content

Commit

Permalink
Gracefully handle small ISO boxes.
Browse files Browse the repository at this point in the history
If they have a weird length, skip them instead of throwing.

Bug: 134443114
Test: atest --test-mapping packages/providers/MediaProvider
Change-Id: I1cb118d5a0486a9e892fbe09a5a1f0faeaaaae56
  • Loading branch information
jsharkey committed Jun 4, 2019
1 parent 08df6aa commit e7e3541
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/com/android/providers/media/util/IsoInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,14 @@ private static int readInt(@NonNull FileDescriptor fd)
}

final long len = Integer.toUnsignedLong(readInt(fd));
final int type = readInt(fd);

if (len <= 0) {
throw new IOException("Invalid box length");
}

if (pos + len > end) {
Log.w(TAG, "Invalid box " + typeToString(type) + " of length " + len
if (len <= 0 || pos + len > end) {
Log.w(TAG, "Invalid box at " + pos + " of length " + len
+ " reached beyond end of parent " + end);
return null;
}

// Skip past legacy data on 'meta' box
final int type = readInt(fd);
if (type == BOX_META) {
readInt(fd);
}
Expand Down

0 comments on commit e7e3541

Please sign in to comment.