diff mbox series

[FFmpeg-devel,2/3] avcodec/iff: Test video_size being non zero

Message ID 20200511203046.4042-2-michael@niedermayer.cc
State Accepted
Commit a035fd88ae7341a05c01f3b393921933e4ea9665
Headers show
Series [FFmpeg-devel,1/3] avcodec/cdtoons: Check sprite_offset is within the packet | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Michael Niedermayer May 11, 2020, 8:30 p.m. UTC
Fixes: Out of array access
Fixes: 20659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5658548592967680
Fixes: 20659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5723561177382912

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/iff.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Michael Niedermayer May 12, 2020, 6:59 p.m. UTC | #1
On Mon, May 11, 2020 at 10:30:45PM +0200, Michael Niedermayer wrote:
> Fixes: Out of array access
> Fixes: 20659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5658548592967680
> Fixes: 20659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5723561177382912
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/iff.c | 2 ++
>  1 file changed, 2 insertions(+)

will apply

[...]
diff mbox series

Patch

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index b39bb2c312..66879cbf5d 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -440,6 +440,8 @@  static av_cold int decode_init(AVCodecContext *avctx)
 
     if (avctx->codec_tag == MKTAG('A', 'N', 'I', 'M')) {
         s->video_size = FFALIGN(avctx->width, 2) * avctx->height * s->bpp;
+        if (!s->video_size)
+            return AVERROR_INVALIDDATA;
         s->video[0] = av_calloc(FFALIGN(avctx->width, 2) * avctx->height, s->bpp);
         s->video[1] = av_calloc(FFALIGN(avctx->width, 2) * avctx->height, s->bpp);
         s->pal = av_calloc(256, sizeof(*s->pal));