From 1493a952ed236c7339566a8cdd42d314fe3184e7 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 25 Sep 2019 01:07:34 +0200 Subject: [PATCH] avcodec/g729_parser: Check block_size 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 Signed-off-by: Michael Niedermayer (cherry picked from commit 972a0a818ff7a9b33c7f37e08783f4b6082f9aa2) Signed-off-by: Michael Niedermayer --- libavcodec/g729_parser.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/g729_parser.c b/libavcodec/g729_parser.c index 9982dbfffc..fc00235d7f 100644 --- a/libavcodec/g729_parser.c +++ b/libavcodec/g729_parser.c @@ -52,6 +52,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) {