[FFmpeg-cvslog] avcodec/notchlc: Check available space for luma block code and alpha code

Michael Niedermayer git at videolan.org
Sun Nov 29 17:16:18 EET 2020


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sat Sep 12 17:05:04 2020 +0200| [3f6653efdb89df08405a6affabf73b26cf499453] | committer: Michael Niedermayer

avcodec/notchlc: Check available space for luma block code and alpha code

Fixes: Timeout (too long -> 2sec)
Fixes: 25439/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_NOTCHLC_fuzzer-5688211127664640

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

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

 libavcodec/notchlc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/notchlc.c b/libavcodec/notchlc.c
index 3f7079da70..57ce70e945 100644
--- a/libavcodec/notchlc.c
+++ b/libavcodec/notchlc.c
@@ -229,6 +229,9 @@ static int decode_blocks(AVCodecContext *avctx, AVFrame *p, ThreadFrame *frame,
     bytestream2_seek(&rgb, s->y_data_row_offsets, SEEK_SET);
     bytestream2_seek(gb, s->y_control_data_offset, SEEK_SET);
 
+    if (bytestream2_get_bytes_left(gb) < (avctx->height + 3) / 4 * ((avctx->width + 3) / 4) * 4)
+        return AVERROR_INVALIDDATA;
+
     dsty = (uint16_t *)p->data[0];
     dsta = (uint16_t *)p->data[3];
     ylinesize = p->linesize[0] / 2;
@@ -277,6 +280,9 @@ static int decode_blocks(AVCodecContext *avctx, AVFrame *p, ThreadFrame *frame,
             dsta += alinesize;
         }
     } else {
+        if (bytestream2_get_bytes_left(gb) < (avctx->height + 15) / 16 * ((avctx->width + 15) / 16) * 8)
+            return AVERROR_INVALIDDATA;
+
         for (int y = 0; y < avctx->height; y += 16) {
             for (int x = 0; x < avctx->width; x += 16) {
                 unsigned m = bytestream2_get_le32(gb);



More information about the ffmpeg-cvslog mailing list