Skip to content

Commit

Permalink
Fix integer underflow in ESDS processing
Browse files Browse the repository at this point in the history
Several arithmetic operations within parseESDescriptor could underflow, leading
to an out-of-bounds read operation. Ensure that subtractions from 'size' do not
cause it to wrap around.

Bug: 20139950

(cherry picked from commit 07c0f59)

Change-Id: I377d21051e07ca654ea1f7037120429d3f71924a
  • Loading branch information
jduck authored and ciwrl committed Jul 7, 2015
1 parent ebf0d09 commit 4a39c15
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions media/libstagefright/ESDS.cpp
Expand Up @@ -136,6 +136,8 @@ status_t ESDS::parseESDescriptor(size_t offset, size_t size) {
--size;

if (streamDependenceFlag) {
if (size < 2)
return ERROR_MALFORMED;
offset += 2;
size -= 2;
}
Expand All @@ -145,11 +147,15 @@ status_t ESDS::parseESDescriptor(size_t offset, size_t size) {
return ERROR_MALFORMED;
}
unsigned URLlength = mData[offset];
if (URLlength >= size)
return ERROR_MALFORMED;
offset += URLlength + 1;
size -= URLlength + 1;
}

if (OCRstreamFlag) {
if (size < 2)
return ERROR_MALFORMED;
offset += 2;
size -= 2;

Expand Down

0 comments on commit 4a39c15

Please sign in to comment.