Skip to content

Commit d227ed5

Browse files
committed
avcodec/mpeg4videodec: Check idx in mpeg4_decode_studio_block()
Fixes: Out of array access Fixes: 13500/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG4_fuzzer-5769760178962432 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Kieran Kunhya <kierank@obe.tv> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
1 parent 3f086a2 commit d227ed5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: libavcodec/mpeg4videodec.c

+6
Original file line numberDiff line numberDiff line change
@@ -1899,14 +1899,20 @@ static int mpeg4_decode_studio_block(MpegEncContext *s, int32_t block[64], int n
18991899
code >>= 1;
19001900
run = (1 << (additional_code_len - 1)) + code;
19011901
idx += run;
1902+
if (idx > 63)
1903+
return AVERROR_INVALIDDATA;
19021904
j = scantable[idx++];
19031905
block[j] = sign ? 1 : -1;
19041906
} else if (group >= 13 && group <= 20) {
19051907
/* Level value (Table B.49) */
1908+
if (idx > 63)
1909+
return AVERROR_INVALIDDATA;
19061910
j = scantable[idx++];
19071911
block[j] = get_xbits(&s->gb, additional_code_len);
19081912
} else if (group == 21) {
19091913
/* Escape */
1914+
if (idx > 63)
1915+
return AVERROR_INVALIDDATA;
19101916
j = scantable[idx++];
19111917
additional_code_len = s->avctx->bits_per_raw_sample + s->dct_precision + 4;
19121918
flc = get_bits(&s->gb, additional_code_len);

0 commit comments

Comments
 (0)