[FFmpeg-devel] [PATCH 2/5] avcodec/smacker: Check input before allocation

Michael Niedermayer michael at niedermayer.cc
Thu Jul 3 23:22:58 EEST 2025


On Thu, Jul 03, 2025 at 09:14:42PM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: Timeout
> > Fixes: 421650030/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMACKAUD_fuzzer-6144441767493632
> > 
> > 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/smacker.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
> > index bd08bc7be28..99009bfd361 100644
> > --- a/libavcodec/smacker.c
> > +++ b/libavcodec/smacker.c
> > @@ -662,6 +662,10 @@ static int smka_decode_frame(AVCodecContext *avctx, AVFrame *frame,
> >          } else
> >              values[i] = h.entries[0].value;
> >      }
> > +    if (get_bits_left(&gb) < (stereo+1) * (bits+1) * 8) {
> > +        ret = AVERROR_INVALIDDATA;
> > +        goto error;
> > +    }
> >  
> >      if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
> >          return ret;
> 
> What about constant output (which you even optimized in
> 08e82e5b572b440f4faf160d2eac923ca47a59f8)?

from this:

    if(bits) { //decode 16-bit data
        for(i = stereo; i >= 0; i--)
            pred[i] = av_bswap16(get_bits(&gb, 16));
...
    } else { //8-bit data
        for(i = stereo; i >= 0; i--)
            pred[i] = get_bits(&gb, 8);
...
    }

I assumed that there are at least (stereo+1) * (bits+1) * 8 bits
bits can only be 0 or 1

did i miss something ?

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Does the universe only have a finite lifespan? No, its going to go on
forever, its just that you wont like living in it. -- Hiranya Peiri
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250703/d27d8357/attachment.sig>


More information about the ffmpeg-devel mailing list