diff mbox

[FFmpeg-devel,3/3] avcodec/iff: finetune the palette size check in the mask case

Message ID 20190622223055.19020-3-michael@niedermayer.cc
State Accepted
Commit 0f9789c8e37eb6d166729e876729beb21b7d5647
Headers show

Commit Message

Michael Niedermayer June 22, 2019, 10:30 p.m. UTC
Fixes: out of array access
Fixes: 15381/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5668057826983936

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, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index b065bbe598..085d7d64b7 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -1523,7 +1523,7 @@  static int decode_frame(AVCodecContext *avctx,
     buf_size -= bytestream2_tell(gb);
     desc = av_pix_fmt_desc_get(avctx->pix_fmt);
 
-    if (!s->init && avctx->bits_per_coded_sample <= 8 &&
+    if (!s->init && avctx->bits_per_coded_sample <= 8 - (s->masking == MASK_HAS_MASK) &&
         avctx->pix_fmt == AV_PIX_FMT_PAL8) {
         if ((res = cmap_read_palette(avctx, (uint32_t *)frame->data[1])) < 0)
             return res;