diff mbox series

[FFmpeg-devel,3/3] avcodec/cbs_h2645: Avoid an unchecked bytesteram read

Message ID 20230725004609.17750-3-michael@niedermayer.cc
State Accepted
Commit 0ba719f726632d73592311615087a0d64aa2fb60
Headers show
Series [FFmpeg-devel,1/3] avformat/imf_cpl: Replace NULL content_title_utf8 by "" | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer July 25, 2023, 12:46 a.m. UTC
The unchecked read caused the 2nd subsequent tell call to move backward resulting
in a negative length

Fixes: assertion failure
Fixes: 60276/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-5434126636023808

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/cbs_h2645.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

James Almer July 25, 2023, 2:28 a.m. UTC | #1
On 7/24/2023 9:46 PM, Michael Niedermayer wrote:
> The unchecked read caused the 2nd subsequent tell call to move backward resulting
> in a negative length
> 
> Fixes: assertion failure
> Fixes: 60276/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-5434126636023808
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>   libavcodec/cbs_h2645.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> index 34c5d1d372..21c8bc76d5 100644
> --- a/libavcodec/cbs_h2645.c
> +++ b/libavcodec/cbs_h2645.c
> @@ -695,7 +695,7 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext *ctx,
>               int nal_unit_type = bytestream2_get_byte(&gbc) & 0x1f;
>               unsigned int num_nalus = 1;
>               if(nal_unit_type != VVC_DCI_NUT && nal_unit_type != VVC_OPI_NUT)
> -                num_nalus = bytestream2_get_be16u(&gbc);
> +                num_nalus = bytestream2_get_be16(&gbc);
>   
>               start = bytestream2_tell(&gbc);
>               for(i = 0; i < num_nalus; i++) {

LGTM.
Michael Niedermayer July 25, 2023, 8:41 p.m. UTC | #2
On Mon, Jul 24, 2023 at 11:28:20PM -0300, James Almer wrote:
> On 7/24/2023 9:46 PM, Michael Niedermayer wrote:
> > The unchecked read caused the 2nd subsequent tell call to move backward resulting
> > in a negative length
> > 
> > Fixes: assertion failure
> > Fixes: 60276/clusterfuzz-testcase-minimized-ffmpeg_BSF_TRACE_HEADERS_fuzzer-5434126636023808
> > 
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >   libavcodec/cbs_h2645.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> > index 34c5d1d372..21c8bc76d5 100644
> > --- a/libavcodec/cbs_h2645.c
> > +++ b/libavcodec/cbs_h2645.c
> > @@ -695,7 +695,7 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext *ctx,
> >               int nal_unit_type = bytestream2_get_byte(&gbc) & 0x1f;
> >               unsigned int num_nalus = 1;
> >               if(nal_unit_type != VVC_DCI_NUT && nal_unit_type != VVC_OPI_NUT)
> > -                num_nalus = bytestream2_get_be16u(&gbc);
> > +                num_nalus = bytestream2_get_be16(&gbc);
> >               start = bytestream2_tell(&gbc);
> >               for(i = 0; i < num_nalus; i++) {
> 
> LGTM.

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 34c5d1d372..21c8bc76d5 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -695,7 +695,7 @@  static int cbs_h2645_split_fragment(CodedBitstreamContext *ctx,
             int nal_unit_type = bytestream2_get_byte(&gbc) & 0x1f;
             unsigned int num_nalus = 1;
             if(nal_unit_type != VVC_DCI_NUT && nal_unit_type != VVC_OPI_NUT)
-                num_nalus = bytestream2_get_be16u(&gbc);
+                num_nalus = bytestream2_get_be16(&gbc);
 
             start = bytestream2_tell(&gbc);
             for(i = 0; i < num_nalus; i++) {