Message ID | 20201014155308.15499-1-michael@niedermayer.cc |
---|---|
State | Superseded |
Headers | show |
Series | [FFmpeg-devel,1/2] avcodec/notchlc: Check uncompressed size against input for LZ4 | expand |
Context | Check | Description |
---|---|---|
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
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@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? > + return AVERROR_INVALIDDATA; > + > av_fast_padded_malloc(&s->uncompressed_buffer, &s->uncompressed_size, > uncompressed_size); > if (!s->uncompressed_buffer) > -- > 2.17.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
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@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 ? thx [...]
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@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)
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) + return AVERROR_INVALIDDATA; + av_fast_padded_malloc(&s->uncompressed_buffer, &s->uncompressed_size, uncompressed_size); if (!s->uncompressed_buffer)
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@niedermayer.cc> --- libavcodec/notchlc.c | 3 +++ 1 file changed, 3 insertions(+)