OSDN Git Service

mxfdec: Sanity check PreviousPartition
authorTomas Härdin <tomas.hardin@codemill.se>
Thu, 26 Jan 2012 12:21:39 +0000 (13:21 +0100)
committerDiego Biurrun <diego@biurrun.de>
Thu, 9 Feb 2012 11:54:05 +0000 (12:54 +0100)
Without this certain files could get the demuxer stuck in a loop.

Signed-off-by: Diego Biurrun <diego@biurrun.de>
libavformat/mxfdec.c

index d305e73..582c120 100644 (file)
@@ -484,6 +484,14 @@ 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;