Skip to content

Commit

Permalink
Check NAL size before use
Browse files Browse the repository at this point in the history
Bug: 24441553
Bug: 24445122
Change-Id: Ib7f025769adbafd5a2cb64fae5562a0a565945c2
(cherry picked from commit 5d10129)
  • Loading branch information
marcone authored and andi34 committed Jun 7, 2016
1 parent 673fa58 commit c714ba4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions media/libstagefright/MPEG4Extractor.cpp
Expand Up @@ -3307,7 +3307,10 @@ status_t MPEG4Source::read(
(const uint8_t *)mBuffer->data() + mBuffer->range_offset();

size_t nal_size = parseNALSize(src);
if (mBuffer->range_length() < mNALLengthSize + nal_size) {
if (mNALLengthSize > SIZE_MAX - nal_size) {
ALOGE("b/24441553, b/24445122");
}
if (mBuffer->range_length() - mNALLengthSize < nal_size) {
ALOGE("incomplete NAL unit.");

mBuffer->release();
Expand Down Expand Up @@ -3572,7 +3575,11 @@ status_t MPEG4Source::fragmentedRead(
(const uint8_t *)mBuffer->data() + mBuffer->range_offset();

size_t nal_size = parseNALSize(src);
if (mBuffer->range_length() < mNALLengthSize + nal_size) {
if (mNALLengthSize > SIZE_MAX - nal_size) {
ALOGE("b/24441553, b/24445122");
}

if (mBuffer->range_length() - mNALLengthSize < nal_size) {
ALOGE("incomplete NAL unit.");

mBuffer->release();
Expand Down

0 comments on commit c714ba4

Please sign in to comment.