aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-04-02 02:18:34 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2019-04-25 14:49:51 +0200
commitaf77adc02e4a814007c50d7fde6ef5e9837ca5a5 (patch)
tree7dfd05e3734ef6dd49a310a47c82ab057ed7e3ca /libavcodec
parent8ea211ab79d646f6d0af0945971ee55f36bfcbc9 (diff)
downloadffmpeg-af77adc02e4a814007c50d7fde6ef5e9837ca5a5.tar.gz
avcodec/qtrle: Check how much of the chunk is available before decoding
Fixes: Timeout (10sec -> 2sec) Fixes: 13979/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QTRLE_fuzzer-5635157718990848 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/qtrle.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavcodec/qtrle.c b/libavcodec/qtrle.c
index 1613530e02..2c29547e5a 100644
--- a/libavcodec/qtrle.c
+++ b/libavcodec/qtrle.c
@@ -452,7 +452,7 @@ static int qtrle_decode_frame(AVCodecContext *avctx,
int header, start_line;
int height, row_ptr;
int has_palette = 0;
- int ret;
+ int ret, size;
bytestream2_init(&s->g, avpkt->data, avpkt->size);
@@ -461,7 +461,10 @@ static int qtrle_decode_frame(AVCodecContext *avctx,
return avpkt->size;
/* start after the chunk size */
- bytestream2_seek(&s->g, 4, SEEK_SET);
+ size = bytestream2_get_be32(&s->g) & 0x3FFFFFFF;
+ if (size - avpkt->size > size * (int64_t)avctx->discard_damaged_percentage / 100)
+ return AVERROR_INVALIDDATA;
+
/* fetch the header */
header = bytestream2_get_be16(&s->g);