avcodec/pngdec: Require a IHDR chunk before fctl
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 29 Jun 2015 19:57:12 +0000 (21:57 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 29 Jun 2015 19:57:12 +0000 (21:57 +0200)
This is required by the APNG spec

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/pngdec.c

index f8b398f..85bc447 100644 (file)
@@ -824,6 +824,11 @@ static int decode_fctl_chunk(AVCodecContext *avctx, PNGDecContext *s,
     if (length != 26)
         return AVERROR_INVALIDDATA;
 
+    if (!(s->state & PNG_IHDR)) {
+        av_log(avctx, AV_LOG_ERROR, "fctl before IHDR\n");
+        return AVERROR_INVALIDDATA;
+    }
+
     s->last_w = s->cur_w;
     s->last_h = s->cur_h;
     s->last_x_offset = s->x_offset;