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 6f5c18da59
)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
@ -384,6 +384,8 @@ static av_always_inline int smk_get_code(GetBitContext *gb, int *recode, int *la
|
|||||||
int v;
|
int v;
|
||||||
|
|
||||||
while(*table & SMK_NODE) {
|
while(*table & SMK_NODE) {
|
||||||
|
if (get_bits_left(gb) < 1)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
if(get_bits1(gb))
|
if(get_bits1(gb))
|
||||||
table += (*table) & (~SMK_NODE);
|
table += (*table) & (~SMK_NODE);
|
||||||
table++;
|
table++;
|
||||||
@ -448,6 +450,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
uint16_t pix;
|
uint16_t pix;
|
||||||
|
|
||||||
type = smk_get_code(&gb, smk->type_tbl, smk->type_last);
|
type = smk_get_code(&gb, smk->type_tbl, smk->type_last);
|
||||||
|
if (type < 0)
|
||||||
|
return type;
|
||||||
run = block_runs[(type >> 2) & 0x3F];
|
run = block_runs[(type >> 2) & 0x3F];
|
||||||
switch(type & 3){
|
switch(type & 3){
|
||||||
case SMK_BLK_MONO:
|
case SMK_BLK_MONO:
|
||||||
|
Reference in New Issue
Block a user