avcodec/jpeg2000dec: check that tp_end is after the start
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 20 Jun 2013 22:31:00 +0000 (00:31 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 20 Jun 2013 22:58:41 +0000 (00:58 +0200)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/jpeg2000dec.c

index caa5ae4..dc976c1 100644 (file)
@@ -1237,6 +1237,10 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
 
             tile = s->tile + s->curtileno;
             tp = tile->tile_part + tile->tp_idx;
+            if (tp->tp_end < s->g.buffer) {
+                av_log(s->avctx, AV_LOG_ERROR, "Invalid tpend\n");
+                return AVERROR_INVALIDDATA;
+            }
             bytestream2_init(&tp->tpg, s->g.buffer, tp->tp_end - s->g.buffer);
             bytestream2_skip(&s->g, tp->tp_end - s->g.buffer);