[FFmpeg-devel] [PATCH] avcodec/pngdec: Check input space

Michael Niedermayer michael at niedermayer.cc
Wed Jun 12 10:33:03 EEST 2019


On Wed, May 15, 2019 at 05:53:49PM +0200, Michael Niedermayer wrote:
> On Tue, May 14, 2019 at 08:52:27PM +0100, Kieran Kunhya wrote:
> > On Tue, 14 May 2019 at 20:42, Michael Niedermayer <michael at niedermayer.cc>
> > wrote:
> > 
> > > Fixes: Timeout (33sec -> 78ms)
> > > Fixes:
> > > 14668/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LSCR_fuzzer-5767073352908800
> > >
> > > Found-by: continuous fuzzing process
> > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > > Signed-off-by
> > > <https://github.com/google/oss-fuzz/tree/master/projects/ffmpegSigned-off-by>:
> > > Michael Niedermayer <michael at niedermayer.cc>
> > > ---
> > >  libavcodec/pngdec.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > >
> > > diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
> > > index 6a681be29d..78988d9e75 100644
> > > --- a/libavcodec/pngdec.c
> > > +++ b/libavcodec/pngdec.c
> > > @@ -1535,6 +1535,9 @@ static int decode_frame_lscr(AVCodecContext *avctx,
> > >      AVFrame *frame = data;
> > >      int ret, nb_blocks, offset = 0;
> > >
> > > +    if (avpkt->size < 2)
> > > +        return AVERROR_INVALIDDATA;
> > > +
> > >
> > 
> > Why not 1?
> 
> because the code reads 2 bytes next:
> 
> nb_blocks = bytestream2_get_le16(gb);
> 
> 
> > Or maybe 3?
> > Or maybe 42?
> 
> Its not checking for 3 or 42 or another number because the smallest
> valid frame that our decoder accepts is 2 bytes.
> In case you have a specification for LSCR, that would be interresting
> to read to see if it contains more constraints which would lead to a
> larger minimum size

will apply the patch in  the next days unless there are objections


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190612/c0cc47aa/attachment.sig>


More information about the ffmpeg-devel mailing list