avcodec/g729_parser: Check block_size
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 24 Sep 2019 23:07:34 +0000 (01:07 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 26 Sep 2019 19:02:34 +0000 (21:02 +0200)
Fixes: Infinite loop
Fixes: 17611/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ACELP_KELVIN_fuzzer-5765134928052224

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

index 5a57025..010f688 100644 (file)
@@ -53,6 +53,12 @@ static int g729_parse(AVCodecParserContext *s1, AVCodecContext *avctx,
         s->duration   = avctx->frame_size;
     }
 
+    if (!s->block_size) {
+        *poutbuf      = buf;
+        *poutbuf_size = buf_size;
+        return buf_size;
+    }
+
     if (!s->remaining)
         s->remaining = s->block_size;
     if (s->remaining <= buf_size) {