Fixes: out of array write Fixes: 60798/clusterfuzz-testcase-minimized-ffmpeg_BSF_EVC_FRAME_MERGE_fuzzer-4633529766772736
Showing the changes to libavcodec (2 of 2 files). Show all
Unified · Split
| @@ -126,7 +126,7 @@ enum { · 125 unmodified lines | ||
| 126 | 126 | |
| 127 | 127 | EVC_MAX_NUM_REF_PICS = 21, |
| 128 | 128 | |
| 129 | − EVC_MAX_NUM_RPLS = 32, | |
| 129 | + EVC_MAX_NUM_RPLS = 64, | |
| 130 | 130 | |
| 131 | 131 | // A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are |
| 132 | 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 | 243 | sps->rpl1_same_as_rpl0_flag = get_bits1(gb); |
| 244 | 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 | 251 | for (int i = 0; i < sps->num_ref_pic_list_in_sps[0]; ++i) |
| 247 | 252 | ref_pic_list_struct(gb, &sps->rpls[0][i]); |
| 248 | 253 | |
| 249 | 254 | if (!sps->rpl1_same_as_rpl0_flag) { |
| 250 | 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 | 260 | for (int i = 0; i < sps->num_ref_pic_list_in_sps[1]; ++i) |
| 252 | 261 | ref_pic_list_struct(gb, &sps->rpls[1][i]); |
| 253 | 262 | } |