avcodec/pngdec: Check trns more completely
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 4 Feb 2017 11:24:14 +0000 (12:24 +0100)
committerMike Gabriel <sunweaver@debian.org>
Sat, 30 Mar 2019 20:44:13 +0000 (20:44 +0000)
Fixes out of array access
Fixes: 546/clusterfuzz-testcase-4809433909559296
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
[sunweaver] ported to libav in Debian jessie LTS (which only supports palette based transparency).

Gbp-Pq: Name CVE-2017-7863.patch

libavcodec/pngdec.c

index 15114034fe652c539919271e83e6b8d5f0f534bf..40b783a0b3b5c95988f0f1d00d6bd92161415c6b 100644 (file)
@@ -592,6 +592,16 @@ static int decode_frame(AVCodecContext *avctx,
         {
             int v, i;
 
+            if (!(s->state & PNG_IHDR)) {
+                av_log(avctx, AV_LOG_ERROR, "trns before IHDR\n");
+                return AVERROR_INVALIDDATA;
+            } 
+
+            if (s->state & PNG_IDAT) {
+                av_log(avctx, AV_LOG_ERROR, "trns after IDAT\n");
+                return AVERROR_INVALIDDATA;
+            }
+
             /* read the transparency. XXX: Only palette mode supported */
             if (s->color_type != PNG_COLOR_TYPE_PALETTE ||
                 length > 256 ||