Skip to content

Commit

Permalink
MPEG4Extractor.cpp: handle chunk_size > SIZE_MAX
Browse files Browse the repository at this point in the history
chunk_size is a uint64_t, so it can legitimately be bigger
than SIZE_MAX, which would cause the subtraction to underflow.

https://code.google.com/p/android/issues/detail?id=182251

Bug: 23034759
Change-Id: Ic1637fb26bf6edb0feb1bcf2876fd370db1ed547
  • Loading branch information
nickkral authored and ciwrl committed Aug 13, 2015
1 parent bbf542d commit 89115df
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion media/libstagefright/MPEG4Extractor.cpp
Expand Up @@ -1961,8 +1961,9 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
size = 0;
}

if (SIZE_MAX - chunk_size <= size)
if ((chunk_size > SIZE_MAX) || (SIZE_MAX - chunk_size <= size)) {
return ERROR_MALFORMED;
}

uint8_t *buffer = new (std::nothrow) uint8_t[size + chunk_size];
if (buffer == NULL) {
Expand Down

0 comments on commit 89115df

Please sign in to comment.