avcodec/smc: Check remaining input
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 25 May 2017 18:07:49 +0000 (20:07 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 25 May 2017 18:08:31 +0000 (20:08 +0200)
Fixes: Timeout
Fixes: 1818/clusterfuzz-testcase-minimized-5039166473633792

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

index 8952421..79f9a75 100644 (file)
@@ -132,6 +132,10 @@ static void smc_decode_stream(SmcContext *s)
                 row_ptr, image_size);
             return;
         }
+        if (bytestream2_get_bytes_left(&s->gb) < 1) {
+            av_log(s->avctx, AV_LOG_ERROR, "input too small\n");
+            return;
+        }
 
         opcode = bytestream2_get_byte(&s->gb);
         switch (opcode & 0xF0) {