Skip to content

Commit

Permalink
Prevent integer underflow if size is below 6
Browse files Browse the repository at this point in the history
When processing 3GPP metadata, a subtraction operation may underflow and
lead to a rather large linear byteswap operation in the subsequent
framedata decoding code. Bound the 'size' value to prevent this from
occurring.

Bug: 20923261
Change-Id: I35dfbc8878c6b65cfe8b8adb7351a77ad4d604e5
(cherry picked from commit 9458e71)
  • Loading branch information
jduck authored and ciwrl committed Jul 14, 2015
1 parent 5fd0cb5 commit d4a13c6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions media/libstagefright/MPEG4Extractor.cpp
Expand Up @@ -2551,6 +2551,10 @@ status_t MPEG4Extractor::parse3GPPMetaData(off64_t offset, size_t size, int dept
int len16 = 0; // Number of UTF-16 characters

// smallest possible valid UTF-16 string w BOM: 0xfe 0xff 0x00 0x00
if (size < 6) {
return ERROR_MALFORMED;
}

if (size - 6 >= 4) {
len16 = ((size - 6) / 2) - 1; // don't include 0x0000 terminator
framedata = (char16_t *)(buffer + 6);
Expand Down

0 comments on commit d4a13c6

Please sign in to comment.