[FFmpeg-cvslog] avcodec/hevc_ps: Check cpb_cnt_minus1 before storing it

Michael Niedermayer git at videolan.org
Thu Oct 19 21:58:54 EEST 2023


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Wed Oct 18 01:50:25 2023 +0200| [5feceed0082c74a3a8e9426dd590c8c61a0c8b88] | committer: Michael Niedermayer

avcodec/hevc_ps: Check cpb_cnt_minus1 before storing it

Fixes: index 32 out of bounds for type 'uint32_t [32]'
Fixes: 63003/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4685160840560640

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5feceed0082c74a3a8e9426dd590c8c61a0c8b88
---

 libavcodec/hevc_ps.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index a6b64b92e3..fb997066d9 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -417,12 +417,13 @@ static int decode_hrd(GetBitContext *gb, int common_inf_present,
             hdr->flags.low_delay_hrd_flag = get_bits1(gb);
 
         if (!hdr->flags.low_delay_hrd_flag) {
-            hdr->cpb_cnt_minus1[i] = get_ue_golomb_long(gb);
-            if (hdr->cpb_cnt_minus1[i] > 31) {
+            unsigned cpb_cnt_minus1 = get_ue_golomb_long(gb);
+            if (cpb_cnt_minus1 > 31) {
                 av_log(NULL, AV_LOG_ERROR, "nb_cpb %d invalid\n",
-                       hdr->cpb_cnt_minus1[i]);
+                       cpb_cnt_minus1);
                 return AVERROR_INVALIDDATA;
             }
+            hdr->cpb_cnt_minus1[i] = cpb_cnt_minus1;
         }
 
         if (hdr->flags.nal_hrd_parameters_present_flag)



More information about the ffmpeg-cvslog mailing list