[FFmpeg-devel] [PATCH 2/2] avcodec/hevc_ps: Dont leave invalid cpb_cnt_minus1 in the context

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Oct 18 16:17:41 EEST 2023


Michael Niedermayer:
> 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>
> ---
>  libavcodec/hevc_ps.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
> index a6b64b92e3..f4365ef5b5 100644
> --- a/libavcodec/hevc_ps.c
> +++ b/libavcodec/hevc_ps.c
> @@ -421,6 +421,7 @@ static int decode_hrd(GetBitContext *gb, int common_inf_present,
>              if (hdr->cpb_cnt_minus1[i] > 31) {
>                  av_log(NULL, AV_LOG_ERROR, "nb_cpb %d invalid\n",
>                         hdr->cpb_cnt_minus1[i]);
> +                hdr->cpb_cnt_minus1[i] = 0;
>                  return AVERROR_INVALIDDATA;
>              }
>          }

There is a second issue here: There can be truncation during the
previous assignment, because cpb_cnt_minus1 is uint8_t. So this should
be fixed by properly checking the value and only putting it in the
parameter set after it has been validated (which also avoids having to
reset it).

- Andreas



More information about the ffmpeg-devel mailing list