aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-04-25 19:18:08 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-11-11 20:18:45 +0100
commitaf511f8a3f590674963c04aad5f66f9c2d2c91b6 (patch)
tree617cf1aa2869d2aec9321ec0238a499ca17e79c7
parent4fee9b6977adeda23715e01fb7d4a7da4a93db7f (diff)
downloadffmpeg-af511f8a3f590674963c04aad5f66f9c2d2c91b6.tar.gz
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/ffmpeg Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit f857753f56f86046d454969e33ba85b3bac99be2) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/gdv.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libavcodec/gdv.c b/libavcodec/gdv.c
index addd513091..d828421199 100644
--- a/libavcodec/gdv.c
+++ b/libavcodec/gdv.c
@@ -425,6 +425,8 @@ static int gdv_decode_frame(AVCodecContext *avctx, void *data,
if (pal && pal_size == 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,
!!(flags & 0x10), !!(flags & 0x20));
@@ -432,8 +434,6 @@ static int gdv_decode_frame(AVCodecContext *avctx, void *data,
case 1:
memset(gdv->frame + PREAMBLE_SIZE, 0, gdv->frame_size - PREAMBLE_SIZE);
case 0:
- if (bytestream2_get_bytes_left(gb) < 256*3)
- return AVERROR_INVALIDDATA;
for (i = 0; i < 256; i++) {
unsigned r = bytestream2_get_byte(gb);
unsigned g = bytestream2_get_byte(gb);