avcodec/lzw: Check for end of input
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 11 Jan 2019 21:38:35 +0000 (22:38 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 16 Jan 2019 00:29:18 +0000 (01:29 +0100)
Fixes: Timeout
Fixes: 11873/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5093495044308992

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

index b0b9a34..e26e482 100644 (file)
@@ -71,6 +71,9 @@ static int lzw_get_code(struct LZWState * s)
 {
     int c;
 
+    if (s->bbits < s->cursize && bytestream2_get_bytes_left(&s->gb) <= 0)
+        return s->end_code;
+
     if(s->mode == FF_LZW_GIF) {
         while (s->bbits < s->cursize) {
             if (!s->bs) {