avcodec/diracdec: Check that slices are fewer than pixels
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 31 Jul 2019 23:49:47 +0000 (01:49 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 13 Aug 2019 20:14:03 +0000 (22:14 +0200)
Fixes: Timeout (197sec ->144ms)
Fixes: 15034/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-5733549405110272

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/diracdec.c

index 7b9e0099dfc992afba5d1ab9f6d6d2356951aef0..22ec913bf7df0c0aade85dc6acda9f2a59b86462 100644 (file)
@@ -1276,7 +1276,9 @@ static int dirac_unpack_idwt_params(DiracContext *s)
         s->num_y        = get_interleaved_ue_golomb(gb);
         if (s->num_x * s->num_y == 0 || s->num_x * (uint64_t)s->num_y > INT_MAX ||
             s->num_x * (uint64_t)s->avctx->width  > INT_MAX ||
-            s->num_y * (uint64_t)s->avctx->height > INT_MAX
+            s->num_y * (uint64_t)s->avctx->height > INT_MAX ||
+            s->num_x > s->avctx->width ||
+            s->num_y > s->avctx->height
         ) {
             av_log(s->avctx,AV_LOG_ERROR,"Invalid numx/y\n");
             s->num_x = s->num_y = 0;