[FFmpeg-cvslog] avcodec/pngdec: Check nb_blocks

Michael Niedermayer git at videolan.org
Sat May 25 03:08:22 EEST 2019


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sat Apr 27 23:49:33 2019 +0200| [4fd74a2b104f3e67f251b67099f5855c386a55bd] | committer: Michael Niedermayer

avcodec/pngdec: Check nb_blocks

Fixes: Timeout (23sec -> 0.5sec)
Fixes: 14329/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LSCR_fuzzer-5679252923482112

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4fd74a2b104f3e67f251b67099f5855c386a55bd
---

 libavcodec/pngdec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 6a681be29d..7fcf83e347 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -1541,6 +1541,8 @@ static int decode_frame_lscr(AVCodecContext *avctx,
         return ret;
 
     nb_blocks = bytestream2_get_le16(gb);
+    if (bytestream2_get_bytes_left(gb) < 2 + nb_blocks * 12)
+        return AVERROR_INVALIDDATA;
 
     if (s->last_picture.f->data[0]) {
         ret = av_frame_copy(frame, s->last_picture.f);



More information about the ffmpeg-cvslog mailing list