]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/cfhd: Check destination space for bayer before writing
authorMichael Niedermayer <michael@niedermayer.cc>
Sun, 4 Aug 2019 10:03:35 +0000 (12:03 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 5 Aug 2019 15:54:24 +0000 (17:54 +0200)
Fixes: out of array write
Fixes: 16105/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5690817309573120
Fixes: 16119/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5099050675732480
Fixes: 16135/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5705501601431552
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/cfhd.c

index a162fc7da38501b30ec80abf142839a944c0b378..27eed415d19fcf28e277a39e04ba156a1c9ce603 100644 (file)
@@ -963,6 +963,15 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,
             }
             low  = s->plane[plane].l_h[6];
             high = s->plane[plane].l_h[7];
+
+            if (avctx->pix_fmt == AV_PIX_FMT_BAYER_RGGB16 &&
+                (lowpass_height * 2 > avctx->coded_height / 2 ||
+                 lowpass_width  * 2 > avctx->coded_width  / 2    )
+                ) {
+                ret = AVERROR_INVALIDDATA;
+                goto end;
+            }
+
             for (i = 0; i < lowpass_height * 2; i++) {
                 if (avctx->pix_fmt == AV_PIX_FMT_BAYER_RGGB16)
                     horiz_filter_clip_bayer(dst, low, high, lowpass_width, s->bpc);