diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2020-10-23 20:39:33 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2021-02-02 14:18:21 +0100 |
commit | 5e880774dcb32e4c5241d77f3c187ee483f1dbba (patch) | |
tree | 1ba75e4ac89fb6c813252c93c612e2a21224bea9 | |
parent | fee0e0ddbf628e1c0f2e1e15c40dc0fa7649d9f8 (diff) | |
download | ffmpeg-5e880774dcb32e4c5241d77f3c187ee483f1dbba.tar.gz |
avcodec/magicyuv: Check slice size before reading flags and pred
Fixes: heap-buffer-overflow
Fixes: 26487/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MAGICYUV_fuzzer-5742553675333632
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 0dc42147b6843b133d4fa46bf1c2568a837b4bec)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavcodec/magicyuv.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c index 5d76274d54..731854959e 100644 --- a/libavcodec/magicyuv.c +++ b/libavcodec/magicyuv.c @@ -695,6 +695,9 @@ static int magy_decode_frame(AVCodecContext *avctx, void *data, s->slices[i][j].start = offset + header_size; s->slices[i][j].size = avpkt->size - s->slices[i][j].start; + + if (s->slices[i][j].size < 2) + return AVERROR_INVALIDDATA; } if (bytestream2_get_byte(&gbyte) != s->planes) |