aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2023-09-14 22:27:46 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2023-09-22 23:47:39 +0200
commit120f74650d924f37285c73c6a78c8fc775b00c09 (patch)
tree7ba685fdc56191b0f3405e4a32aa612d3636011a /libavcodec
parent87cf1be90508465674fbdf55e350a03070e0d6af (diff)
downloadffmpeg-120f74650d924f37285c73c6a78c8fc775b00c09.tar.gz
avcodec/evc_ps: Check cpb_cnt_minus1 and propagate error
Fixes: out of array access Fixes: 60949/clusterfuzz-testcase-minimized-ffmpeg_dem_EVC_fuzzer-5959738853294080 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/evc_ps.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/libavcodec/evc_ps.c b/libavcodec/evc_ps.c
index 6f93f5b373..be27386292 100644
--- a/libavcodec/evc_ps.c
+++ b/libavcodec/evc_ps.c
@@ -57,6 +57,9 @@ static int ref_pic_list_struct(const EVCParserSPS *sps, GetBitContext *gb, RefPi
static int hrd_parameters(GetBitContext *gb, HRDParameters *hrd)
{
hrd->cpb_cnt_minus1 = get_ue_golomb_31(gb);
+ if (hrd->cpb_cnt_minus1 >= FF_ARRAY_ELEMS(hrd->cpb_size_value_minus1))
+ return AVERROR_INVALIDDATA;
+
hrd->bit_rate_scale = get_bits(gb, 4);
hrd->cpb_size_scale = get_bits(gb, 4);
for (int SchedSelIdx = 0; SchedSelIdx <= hrd->cpb_cnt_minus1; SchedSelIdx++) {
@@ -75,6 +78,8 @@ static int hrd_parameters(GetBitContext *gb, HRDParameters *hrd)
// @see ISO_IEC_23094-1 (E.2.1 VUI parameters syntax)
static int vui_parameters(GetBitContext *gb, VUIParameters *vui)
{
+ int ret;
+
vui->aspect_ratio_info_present_flag = get_bits(gb, 1);
if (vui->aspect_ratio_info_present_flag) {
vui->aspect_ratio_idc = get_bits(gb, 8);
@@ -113,11 +118,18 @@ static int vui_parameters(GetBitContext *gb, VUIParameters *vui)
vui->fixed_pic_rate_flag = get_bits(gb, 1);
}
vui->nal_hrd_parameters_present_flag = get_bits(gb, 1);
- if (vui->nal_hrd_parameters_present_flag)
- hrd_parameters(gb, &vui->hrd_parameters);
+ if (vui->nal_hrd_parameters_present_flag) {
+ ret = hrd_parameters(gb, &vui->hrd_parameters);
+ if (ret < 0)
+ return ret;
+ }
+
vui->vcl_hrd_parameters_present_flag = get_bits(gb, 1);
- if (vui->vcl_hrd_parameters_present_flag)
- hrd_parameters(gb, &vui->hrd_parameters);
+ if (vui->vcl_hrd_parameters_present_flag) {
+ ret = hrd_parameters(gb, &vui->hrd_parameters);
+ if (ret < 0)
+ return ret;
+ }
if (vui->nal_hrd_parameters_present_flag || vui->vcl_hrd_parameters_present_flag)
vui->low_delay_hrd_flag = get_bits(gb, 1);
vui->pic_struct_present_flag = get_bits(gb, 1);
@@ -304,8 +316,11 @@ int ff_evc_parse_sps(GetBitContext *gb, EVCParamSets *ps)
}
sps->vui_parameters_present_flag = get_bits1(gb);
- if (sps->vui_parameters_present_flag)
- vui_parameters(gb, &(sps->vui_parameters));
+ if (sps->vui_parameters_present_flag) {
+ ret = vui_parameters(gb, &(sps->vui_parameters));
+ if (ret < 0)
+ goto fail;
+ }
// @note
// If necessary, add the missing fields to the EVCParserSPS structure