Commit af511f8a authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/gdv: Check input palette size before rescale()

Fixes: Timeout (22sec -> 11sec)
Fixes: 13576/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_GDV_fuzzer-5681024577568768

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpegReviewed-by: 's avatarPaul B Mahol <onemda@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit f857753f)
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 4fee9b69
...@@ -425,6 +425,8 @@ static int gdv_decode_frame(AVCodecContext *avctx, void *data, ...@@ -425,6 +425,8 @@ static int gdv_decode_frame(AVCodecContext *avctx, void *data,
if (pal && pal_size == AVPALETTE_SIZE) if (pal && pal_size == AVPALETTE_SIZE)
memcpy(gdv->pal, pal, AVPALETTE_SIZE); memcpy(gdv->pal, pal, AVPALETTE_SIZE);
if (compression < 2 && bytestream2_get_bytes_left(gb) < 256*3)
return AVERROR_INVALIDDATA;
rescale(gdv, gdv->frame, avctx->width, avctx->height, rescale(gdv, gdv->frame, avctx->width, avctx->height,
!!(flags & 0x10), !!(flags & 0x20)); !!(flags & 0x10), !!(flags & 0x20));
...@@ -432,8 +434,6 @@ static int gdv_decode_frame(AVCodecContext *avctx, void *data, ...@@ -432,8 +434,6 @@ static int gdv_decode_frame(AVCodecContext *avctx, void *data,
case 1: case 1:
memset(gdv->frame + PREAMBLE_SIZE, 0, gdv->frame_size - PREAMBLE_SIZE); memset(gdv->frame + PREAMBLE_SIZE, 0, gdv->frame_size - PREAMBLE_SIZE);
case 0: case 0:
if (bytestream2_get_bytes_left(gb) < 256*3)
return AVERROR_INVALIDDATA;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
unsigned r = bytestream2_get_byte(gb); unsigned r = bytestream2_get_byte(gb);
unsigned g = bytestream2_get_byte(gb); unsigned g = bytestream2_get_byte(gb);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment