]> git.sesse.net Git - ffmpeg/commitdiff
mxfdec: Sanity check PreviousPartition
authorTomas Härdin <tomas.hardin@codemill.se>
Wed, 21 Dec 2011 09:56:59 +0000 (10:56 +0100)
committerTomas Härdin <tomas.hardin@codemill.se>
Wed, 21 Dec 2011 13:17:44 +0000 (14:17 +0100)
Without this certain files could get the demuxer stuck in a loop

libavformat/mxfdec.c

index e1363747a9aa29920c3d368b7c44004b3b3f8984..15c2a21e1d26bec2c41667b39d0ccaa99cb0f168 100644 (file)
@@ -479,6 +479,13 @@ static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size
             partition->previous_partition, footer_partition,
             partition->index_sid, partition->body_sid);
 
+    /* sanity check PreviousPartition if set */
+    if (partition->previous_partition &&
+        mxf->run_in + partition->previous_partition >= klv_offset) {
+        av_log(mxf->fc, AV_LOG_ERROR, "PreviousPartition points to this partition or forward\n");
+        return AVERROR_INVALIDDATA;
+    }
+
     if      (op[12] == 1 && op[13] == 1) mxf->op = OP1a;
     else if (op[12] == 1 && op[13] == 2) mxf->op = OP1b;
     else if (op[12] == 1 && op[13] == 3) mxf->op = OP1c;