avcodec/cbs_h265_syntax_template: Check num_negative/positive_pics when inter_ref_pic_set_prediction_flag is set

Fixes: out of array access
Fixes: 20446/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-5707770718584832

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 588114cea4)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2020-04-05 00:11:15 +02:00
parent f358a4d68d
commit 8ce3cf4343
1 changed files with 4 additions and 0 deletions

View File

@ -545,6 +545,8 @@ static int FUNC(st_ref_pic_set)(CodedBitstreamContext *ctx, RWContext *rw,
} }
} }
if (i > 15)
return AVERROR_INVALIDDATA;
infer(num_negative_pics, i); infer(num_negative_pics, i);
for (i = 0; i < current->num_negative_pics; i++) { for (i = 0; i < current->num_negative_pics; i++) {
infer(delta_poc_s0_minus1[i], infer(delta_poc_s0_minus1[i],
@ -574,6 +576,8 @@ static int FUNC(st_ref_pic_set)(CodedBitstreamContext *ctx, RWContext *rw,
} }
} }
if (i + current->num_negative_pics > 15)
return AVERROR_INVALIDDATA;
infer(num_positive_pics, i); infer(num_positive_pics, i);
for (i = 0; i < current->num_positive_pics; i++) { for (i = 0; i < current->num_positive_pics; i++) {
infer(delta_poc_s1_minus1[i], infer(delta_poc_s1_minus1[i],