Fixes: out of array write Fixes: 60798/clusterfuzz-testcase-minimized-ffmpeg_BSF_EVC_FRAME_MERGE_fuzzer-4633529766772736
Unified · Split
| @@ -126,7 +126,7 @@ enum { · 125 unmodified lines | |||
| 126 | 126 | ||
| 127 | EVC_MAX_NUM_REF_PICS = 21, | 127 | EVC_MAX_NUM_REF_PICS = 21, |
| 128 | 128 | ||
| 129 | EVC_MAX_NUM_RPLS = 32, | 129 | EVC_MAX_NUM_RPLS = 64, |
| 130 | 130 | ||
| 131 | // A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are | 131 | // A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are |
| 132 | // constrained to be not greater than sqrt(MaxLumaPs * 8). Hence height/ | 132 | // constrained to be not greater than sqrt(MaxLumaPs * 8). Hence height/ |
| @@ -243,11 +243,20 @@ int ff_evc_parse_sps(GetBitContext *gb, EVCParamSets *ps) · 242 unmodified lines | |||
| 243 | sps->rpl1_same_as_rpl0_flag = get_bits1(gb); | 243 | sps->rpl1_same_as_rpl0_flag = get_bits1(gb); |
| 244 | sps->num_ref_pic_list_in_sps[0] = get_ue_golomb(gb); | 244 | sps->num_ref_pic_list_in_sps[0] = get_ue_golomb(gb); |
| 245 | 245 | ||
| 246 | if ((unsigned)sps->num_ref_pic_list_in_sps[0] >= EVC_MAX_NUM_RPLS) { | ||
| 247 | ret = AVERROR_INVALIDDATA; | ||
| 248 | goto fail; | ||
| 249 | } | ||
| 250 | |||
| 246 | for (int i = 0; i < sps->num_ref_pic_list_in_sps[0]; ++i) | 251 | for (int i = 0; i < sps->num_ref_pic_list_in_sps[0]; ++i) |
| 247 | ref_pic_list_struct(gb, &sps->rpls[0][i]); | 252 | ref_pic_list_struct(gb, &sps->rpls[0][i]); |
| 248 | 253 | ||
| 249 | if (!sps->rpl1_same_as_rpl0_flag) { | 254 | if (!sps->rpl1_same_as_rpl0_flag) { |
| 250 | sps->num_ref_pic_list_in_sps[1] = get_ue_golomb(gb); | 255 | sps->num_ref_pic_list_in_sps[1] = get_ue_golomb(gb); |
| 256 | if ((unsigned)sps->num_ref_pic_list_in_sps[1] >= EVC_MAX_NUM_RPLS) { | ||
| 257 | ret = AVERROR_INVALIDDATA; | ||
| 258 | goto fail; | ||
| 259 | } | ||
| 251 | for (int i = 0; i < sps->num_ref_pic_list_in_sps[1]; ++i) | 260 | for (int i = 0; i < sps->num_ref_pic_list_in_sps[1]; ++i) |
| 252 | ref_pic_list_struct(gb, &sps->rpls[1][i]); | 261 | ref_pic_list_struct(gb, &sps->rpls[1][i]); |
| 253 | } | 262 | } |