[FFmpeg-devel] [PATCH 1/2] avcodec/notchlc: Check uncompressed size against input for LZ4

Paul B Mahol onemda at gmail.com
Wed Oct 14 22:55:17 EEST 2020


On Wed, Oct 14, 2020 at 09:17:40PM +0200, Michael Niedermayer wrote:
> On Wed, Oct 14, 2020 at 07:54:34PM +0200, Paul B Mahol wrote:
> > On Wed, Oct 14, 2020 at 05:53:07PM +0200, Michael Niedermayer wrote:
> > > Fixes: OOM
> > > Fixes: 26168/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NOTCHLC_fuzzer-6019839015256064
> > > 
> > > 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/notchlc.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/libavcodec/notchlc.c b/libavcodec/notchlc.c
> > > index 3f7079da70..0254e7d76a 100644
> > > --- a/libavcodec/notchlc.c
> > > +++ b/libavcodec/notchlc.c
> > > @@ -490,6 +490,9 @@ static int decode_frame(AVCodecContext *avctx,
> > >  
> > >          bytestream2_init(gb, s->lzf_buffer, uncompressed_size);
> > >      } else if (s->format == 1) {
> > > +        if (bytestream2_get_bytes_left(gb) < uncompressed_size / 255)
> > 
> > From where you picked this division? And expecially 255 number?
> 
> from a look at lz4_decompress(), it appeared to me that the amount
> of bytes output is encoded so that each 255 bytes output require a byte
> input. So the output would be bound to 255 times the input size
> Did i miss something ?

#define LZ4_MAX_INPUT_SIZE        0x7E000000   /* 2 113 929 216 bytes */
#define LZ4_COMPRESSBOUND(isize)  ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)


More information about the ffmpeg-devel mailing list