OSDN Git Service

Check buffer size before using it
authorMarco Nelissen <marcone@google.com>
Wed, 1 Jul 2015 20:05:50 +0000 (13:05 -0700)
committerAbhishek Arya <aarya@google.com>
Sat, 15 Aug 2015 03:59:05 +0000 (03:59 +0000)
Bug: 21814993
Change-Id: Idaac61b4b9f4058b94e84093644593ba315d72ff
(cherry picked from commit c1a104aaad2d84a57bf5d87dd030d2bef56bf541)

media/libstagefright/MPEG4Extractor.cpp

index 56bd875..46010ca 100644 (file)
@@ -3193,6 +3193,10 @@ status_t MPEG4Source::read(
             CHECK(mBuffer == NULL);
             return err;
         }
+        if (size > mBuffer->size()) {
+            ALOGE("buffer too small: %zu > %zu", size, mBuffer->size());
+            return ERROR_BUFFER_TOO_SMALL;
+        }
     }
 
     if (!mIsAVC || mWantsNALFragments) {
@@ -3439,6 +3443,10 @@ status_t MPEG4Source::fragmentedRead(
             ALOGV("acquire_buffer returned %d", err);
             return err;
         }
+        if (size > mBuffer->size()) {
+            ALOGE("buffer too small: %zu > %zu", size, mBuffer->size());
+            return ERROR_BUFFER_TOO_SMALL;
+        }
     }
 
     const Sample *smpl = &mCurrentSamples[mCurrentSampleIndex];