diff mbox

[FFmpeg-devel] avcodec/hq_hqa: Check available space before reading slice offsets

Message ID 20190511232733.28039-1-michael@niedermayer.cc
State Accepted
Commit 407e7c34ca8a3047e4f1b14287053638b4add68d
Headers show

Commit Message

Michael Niedermayer May 11, 2019, 11:27 p.m. UTC
Fixes: Timeout (43sec -> 18sec)
Fixes: 14556/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HQ_HQA_fuzzer-5673543024508928

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/hq_hqa.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Paul B Mahol May 12, 2019, 7:45 a.m. UTC | #1
On 5/12/19, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: Timeout (43sec -> 18sec)
> Fixes:
> 14556/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HQ_HQA_fuzzer-5673543024508928
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/hq_hqa.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c
> index ec9da3e04f..90bafdc72a 100644
> --- a/libavcodec/hq_hqa.c
> +++ b/libavcodec/hq_hqa.c
> @@ -248,6 +248,9 @@ static int hqa_decode_frame(HQContext *ctx, AVFrame
> *pic, size_t data_size)
>      int width, height, quant;
>      const uint8_t *src = ctx->gbc.buffer;
>
> +    if (bytestream2_get_bytes_left(&ctx->gbc) < 8 + 4*(num_slices + 1))
> +        return AVERROR_INVALIDDATA;
> +
>      width  = bytestream2_get_be16(&ctx->gbc);
>      height = bytestream2_get_be16(&ctx->gbc);
>

LGTM

> --
> 2.21.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 May 12, 2019, 12:34 p.m. UTC | #2
On Sun, May 12, 2019 at 09:45:59AM +0200, Paul B Mahol wrote:
> On 5/12/19, Michael Niedermayer <michael@niedermayer.cc> wrote:
> > Fixes: Timeout (43sec -> 18sec)
> > Fixes:
> > 14556/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HQ_HQA_fuzzer-5673543024508928
> >
> > Found-by: continuous fuzzing process
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/hq_hqa.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c
> > index ec9da3e04f..90bafdc72a 100644
> > --- a/libavcodec/hq_hqa.c
> > +++ b/libavcodec/hq_hqa.c
> > @@ -248,6 +248,9 @@ static int hqa_decode_frame(HQContext *ctx, AVFrame
> > *pic, size_t data_size)
> >      int width, height, quant;
> >      const uint8_t *src = ctx->gbc.buffer;
> >
> > +    if (bytestream2_get_bytes_left(&ctx->gbc) < 8 + 4*(num_slices + 1))
> > +        return AVERROR_INVALIDDATA;
> > +
> >      width  = bytestream2_get_be16(&ctx->gbc);
> >      height = bytestream2_get_be16(&ctx->gbc);
> >
> 
> LGTM

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c
index ec9da3e04f..90bafdc72a 100644
--- a/libavcodec/hq_hqa.c
+++ b/libavcodec/hq_hqa.c
@@ -248,6 +248,9 @@  static int hqa_decode_frame(HQContext *ctx, AVFrame *pic, size_t data_size)
     int width, height, quant;
     const uint8_t *src = ctx->gbc.buffer;
 
+    if (bytestream2_get_bytes_left(&ctx->gbc) < 8 + 4*(num_slices + 1))
+        return AVERROR_INVALIDDATA;
+
     width  = bytestream2_get_be16(&ctx->gbc);
     height = bytestream2_get_be16(&ctx->gbc);