caf: fix 'pakt' chunk parsing
authorJustin Ruggles <justin.ruggles@gmail.com>
Mon, 9 Jul 2012 18:10:52 +0000 (14:10 -0400)
committerJustin Ruggles <justin.ruggles@gmail.com>
Thu, 19 Jul 2012 17:26:45 +0000 (13:26 -0400)
according to the CAF specification:
"... the value for mChunkSize can be greater than the actual valid content
of the packet table chunk"

libavformat/cafdec.c

index 4a04cb0..90e97a1 100644 (file)
@@ -192,10 +192,11 @@ static int read_pakt_chunk(AVFormatContext *s, int64_t size)
         st->duration += caf->frames_per_packet ? caf->frames_per_packet : ff_mp4_read_descr_len(pb);
     }
 
-    if (avio_tell(pb) - ccount != size) {
+    if (avio_tell(pb) - ccount > size) {
         av_log(s, AV_LOG_ERROR, "error reading packet table\n");
-        return -1;
+        return AVERROR_INVALIDDATA;
     }
+    avio_skip(pb, ccount + size - avio_tell(pb));
 
     caf->num_bytes = pos;
     return 0;