aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/hevc_ps.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2023-04-09 14:31:16 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2023-04-14 17:56:44 +0200
commit80ac1fd1483a4b3c92a6e59d24cb050dfecb90df (patch)
tree01b9312badb09edfb8611d2993ca2052f92252f7 /libavcodec/hevc_ps.c
parent27e7857bd1127974ffe1512293abee83b1035194 (diff)
downloadffmpeg-80ac1fd1483a4b3c92a6e59d24cb050dfecb90df.tar.gz
avcodec/hevc_ps: Check num_ref_loc_offsets
Fixes: Writing arbitrarily over the array end Fixes: 57812/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4536557859373056 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/hevc_ps.c')
-rw-r--r--libavcodec/hevc_ps.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 348e4d8de2..be1d668c26 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -1392,6 +1392,10 @@ static int pps_multilayer_extension(GetBitContext *gb, AVCodecContext *avctx,
pps->pps_scaling_list_ref_layer_id = get_bits(gb, 6);
pps->num_ref_loc_offsets = get_ue_golomb_long(gb);
+ if (pps->num_ref_loc_offsets > FF_ARRAY_ELEMS(pps->ref_loc_offset_layer_id)) {
+ pps->num_ref_loc_offsets = 0;
+ return AVERROR_INVALIDDATA;
+ }
for (int i = 0; i < pps->num_ref_loc_offsets; i++) {
pps->ref_loc_offset_layer_id[i] = get_bits(gb, 6);
pps->scaled_ref_layer_offset_present_flag[i] = get_bits1(gb);