Bug 1180101 - Skip four bytes when we hit a zero length box; r=jya, a=sylvestre
authorAnthony Jones <ajones@mozilla.com>
Wed, 26 Aug 2015 18:12:59 +1200
changeset 289551 3011eba21201
parent 289550 70717f9ec55a
child 289552 8b303a74c515
push id5183
push usercbook@mozilla.com
push date2015-10-15 14:01 +0000
treeherdermozilla-beta@8b303a74c515 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya, sylvestre
bugs1180101
milestone42.0
Bug 1180101 - Skip four bytes when we hit a zero length box; r=jya, a=sylvestre
media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
--- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
@@ -739,17 +739,24 @@ static bool ValidInputSize(int32_t size)
   // frame. This is a reasonable cut-off for a lossy codec,
   // combined with the current Firefox limit to 5k video.
   return (size > 0 && size <= 4 * (1920 * 1080) * 3 / 2);
 }
 
 status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
     ALOGV("entering parseChunk %lld/%d", *offset, depth);
     uint32_t hdr[2];
-    if (mDataSource->readAt(*offset, hdr, 8) < 8) {
+    ssize_t nbytes;
+    if ((nbytes = mDataSource->readAt(*offset, hdr, 8)) < 8) {
+        if (nbytes == 4) {
+          if (!hdr[0]) {
+            *offset += 4;
+            return OK;
+          }
+        }
         return ERROR_IO;
     }
     uint64_t chunk_size = ntohl(hdr[0]);
     uint32_t chunk_type = ntohl(hdr[1]);
     off64_t data_offset = *offset + 8;
 
     if (chunk_size == 1) {
         if (mDataSource->readAt(*offset + 8, &chunk_size, 8) < 8) {