diff mbox series

[FFmpeg-devel,2/3] avcodec/vp3: Check version in all cases when VP4 code is not built

Message ID 20211130195935.29259-2-michael@niedermayer.cc
State Accepted
Commit 96caa01f130526cb420d0706a40fb63695153128
Headers show
Series [FFmpeg-devel,1/3] tools/target_dec_fuzzer: Adjust DXA threshold
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Michael Niedermayer Nov. 30, 2021, 7:59 p.m. UTC
Fixes: out of array read
Fixes: 40284/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-4599568176644096

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

Comments

Peter Ross Dec. 1, 2021, 5:14 a.m. UTC | #1
On Tue, Nov 30, 2021 at 08:59:34PM +0100, Michael Niedermayer wrote:
> Fixes: out of array read
> Fixes: 40284/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-4599568176644096
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/vp3.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> index 16726080b35..5b9ba60f499 100644
> --- a/libavcodec/vp3.c
> +++ b/libavcodec/vp3.c
> @@ -2685,7 +2685,14 @@ static int vp3_decode_frame(AVCodecContext *avctx,
>              skip_bits(&gb, 4); /* width code */
>              skip_bits(&gb, 4); /* height code */
>              if (s->version) {
> -                s->version = get_bits(&gb, 5);
> +                int version = get_bits(&gb, 5);
> +#if !CONFIG_VP4_DECODER
> +                if (version >= 2) {
> +                    av_log(avctx, AV_LOG_ERROR, "This build does not support decoding VP4.\n");
> +                    return AVERROR_DECODER_NOT_FOUND;
> +                }
> +#endif
> +                s->version = version;
>                  if (avctx->frame_number == 0)
>                      av_log(s->avctx, AV_LOG_DEBUG,
>                             "VP version: %d\n", s->version);

please apply.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Michael Niedermayer Dec. 1, 2021, 4:29 p.m. UTC | #2
On Wed, Dec 01, 2021 at 04:14:20PM +1100, Peter Ross wrote:
> On Tue, Nov 30, 2021 at 08:59:34PM +0100, Michael Niedermayer wrote:
> > Fixes: out of array read
> > Fixes: 40284/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-4599568176644096
> > 
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/vp3.c | 9 ++++++++-
> >  1 file changed, 8 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> > index 16726080b35..5b9ba60f499 100644
> > --- a/libavcodec/vp3.c
> > +++ b/libavcodec/vp3.c
> > @@ -2685,7 +2685,14 @@ static int vp3_decode_frame(AVCodecContext *avctx,
> >              skip_bits(&gb, 4); /* width code */
> >              skip_bits(&gb, 4); /* height code */
> >              if (s->version) {
> > -                s->version = get_bits(&gb, 5);
> > +                int version = get_bits(&gb, 5);
> > +#if !CONFIG_VP4_DECODER
> > +                if (version >= 2) {
> > +                    av_log(avctx, AV_LOG_ERROR, "This build does not support decoding VP4.\n");
> > +                    return AVERROR_DECODER_NOT_FOUND;
> > +                }
> > +#endif
> > +                s->version = version;
> >                  if (avctx->frame_number == 0)
> >                      av_log(s->avctx, AV_LOG_DEBUG,
> >                             "VP version: %d\n", s->version);
> 
> please apply.

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 16726080b35..5b9ba60f499 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -2685,7 +2685,14 @@  static int vp3_decode_frame(AVCodecContext *avctx,
             skip_bits(&gb, 4); /* width code */
             skip_bits(&gb, 4); /* height code */
             if (s->version) {
-                s->version = get_bits(&gb, 5);
+                int version = get_bits(&gb, 5);
+#if !CONFIG_VP4_DECODER
+                if (version >= 2) {
+                    av_log(avctx, AV_LOG_ERROR, "This build does not support decoding VP4.\n");
+                    return AVERROR_DECODER_NOT_FOUND;
+                }
+#endif
+                s->version = version;
                 if (avctx->frame_number == 0)
                     av_log(s->avctx, AV_LOG_DEBUG,
                            "VP version: %d\n", s->version);