diff mbox

[FFmpeg-devel,4/4] avcodec/g729_parser: Check block_size

Message ID 20190925100120.12305-4-michael@niedermayer.cc
State Accepted
Commit 972a0a818ff7a9b33c7f37e08783f4b6082f9aa2
Headers show

Commit Message

Michael Niedermayer Sept. 25, 2019, 10:01 a.m. UTC
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
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/g729_parser.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Paul B Mahol Sept. 25, 2019, 10:39 a.m. UTC | #1
lgtm

On 9/25/19, Michael Niedermayer <michael@niedermayer.cc> wrote:
> 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
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/g729_parser.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/libavcodec/g729_parser.c b/libavcodec/g729_parser.c
> index 5a57025d62..010f688104 100644
> --- a/libavcodec/g729_parser.c
> +++ b/libavcodec/g729_parser.c
> @@ -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) {
> --
> 2.23.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Michael Niedermayer Sept. 26, 2019, 6:30 p.m. UTC | #2
On Wed, Sep 25, 2019 at 12:39:10PM +0200, Paul B Mahol wrote:
> lgtm

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavcodec/g729_parser.c b/libavcodec/g729_parser.c
index 5a57025d62..010f688104 100644
--- a/libavcodec/g729_parser.c
+++ b/libavcodec/g729_parser.c
@@ -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) {