summaryrefslogtreecommitdiff
path: root/libavcodec/smacker.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-01-01 20:43:05 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2020-07-01 13:33:44 +0200
commitddd6e68fff668c993239c3f83faabd3a0d944a63 (patch)
tree5ccba55a820e82286f03397c113d1e10dd6ef25a /libavcodec/smacker.c
parentdeef4666521a75b2c3952b953d21824e4cb1e5a3 (diff)
downloadffmpeg-ddd6e68fff668c993239c3f83faabd3a0d944a63.tar.gz
avcodec/smacker: Check space before decoding type
Fixes: Timeout (232sec -> 280ms) Fixes: 19682/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMACKER_fuzzer-5654129649385472 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 6f5c18da5977a3214e1ea30e6b0c0d9d858ce83d) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/smacker.c')
-rw-r--r--libavcodec/smacker.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index 3e3eed9f7e..e9810b1be7 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -391,6 +391,8 @@ static av_always_inline int smk_get_code(GetBitContext *gb, int *recode, int *la
int v;
while(*table & SMK_NODE) {
+ if (get_bits_left(gb) < 1)
+ return AVERROR_INVALIDDATA;
if(get_bits1(gb))
table += (*table) & (~SMK_NODE);
table++;
@@ -455,6 +457,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
uint16_t pix;
type = smk_get_code(&gb, smk->type_tbl, smk->type_last);
+ if (type < 0)
+ return type;
run = block_runs[(type >> 2) & 0x3F];
switch(type & 3){
case SMK_BLK_MONO: