]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/magicyuv: Check that there are enough lines for interlacing to be possible
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 21 Feb 2020 23:42:30 +0000 (00:42 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 25 Feb 2020 18:57:16 +0000 (19:57 +0100)
Fixes: out of array access
Fixes: 20763/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MAGICYUV_fuzzer-5759562508664832
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/magicyuv.c

index 21a32785bc845139f6725b0d1fa0d390d034f1a4..aacd0d4d7dc42d8549e435a1ec825f8da622fea8 100644 (file)
@@ -659,6 +659,17 @@ static int magy_decode_frame(AVCodecContext *avctx, void *data,
         return AVERROR_INVALIDDATA;
     }
 
+    if (s->interlaced) {
+        if ((s->slice_height >> s->vshift[1]) < 2) {
+            av_log(avctx, AV_LOG_ERROR, "impossible slice height\n");
+            return AVERROR_INVALIDDATA;
+        }
+        if ((avctx->coded_height % s->slice_height) && ((avctx->coded_height % s->slice_height) >> s->vshift[1]) < 2) {
+            av_log(avctx, AV_LOG_ERROR, "impossible height\n");
+            return AVERROR_INVALIDDATA;
+        }
+    }
+
     for (i = 0; i < s->planes; i++) {
         av_fast_malloc(&s->slices[i], &s->slices_size[i], s->nb_slices * sizeof(Slice));
         if (!s->slices[i])