]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/lscrdec: Check length in decode_idat()
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 30 Mar 2021 11:17:09 +0000 (13:17 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 1 Apr 2021 08:10:21 +0000 (10:10 +0200)
Fixes: out of array access
Fixes: 32264/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LSCR_fuzzer-6684504010915840
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/lscrdec.c

index f5cfe1fa045edde8523cf57c73bf10fe2ae119ff..042da84bf9030eb46f07ebf606e43c8d5a5a6625 100644 (file)
@@ -76,6 +76,10 @@ static int decode_idat(LSCRContext *s, int length)
     int ret;
     s->zstream.avail_in = FFMIN(length, bytestream2_get_bytes_left(&s->gb));
     s->zstream.next_in  = s->gb.buffer;
+
+    if (length <= 0)
+        return AVERROR_INVALIDDATA;
+
     bytestream2_skip(&s->gb, length);
 
     /* decode one line if possible */