summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <[email protected]>2020-02-22 00:42:30 +0100
committerMichael Niedermayer <[email protected]>2020-07-01 13:33:44 +0200
commit447e97e51054b5b4cc84e29d38732ea63e22748a (patch)
treef24382298b033f71d1e41a50a305deb63dc0b2a7
parent07a265b140f8698c73eec2f1f108b8a1914ca3c4 (diff)
avcodec/magicyuv: Check that there are enough lines for interlacing to be possible
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 <[email protected]> Signed-off-by: Michael Niedermayer <[email protected]> (cherry picked from commit f8a0e9f9f71cf5650bdc250ff7475e0f7d8e8420) Signed-off-by: Michael Niedermayer <[email protected]>
-rw-r--r--libavcodec/magicyuv.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c
index 1a129c2619..54a5ce0192 100644
--- a/libavcodec/magicyuv.c
+++ b/libavcodec/magicyuv.c
@@ -670,6 +670,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])