diff mbox

[FFmpeg-devel,1/4] avcodec/vp3: Check for end of input in 2 places of vp4_unpack_macroblocks()

Message ID 20190901211028.4759-1-michael@niedermayer.cc
State Accepted
Commit daf92cc074c5e2ddd567016ac8b142cbd0add43c
Headers show

Commit Message

Michael Niedermayer Sept. 1, 2019, 9:10 p.m. UTC
Fixes: Timeout (82sec -> 1sec)
Fixes: 16411/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-5166958151991296

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 | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Peter Ross Sept. 2, 2019, 8:33 a.m. UTC | #1
On Sun, Sep 01, 2019 at 11:10:25PM +0200, Michael Niedermayer wrote:
> Fixes: Timeout (82sec -> 1sec)
> Fixes: 16411/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-5166958151991296
> 
> 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 | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> index 28ed0461c7..a2bd2ef07d 100644
> --- a/libavcodec/vp3.c
> +++ b/libavcodec/vp3.c
> @@ -710,6 +710,8 @@ static int vp4_unpack_macroblocks(Vp3DecodeContext *s, GetBitContext *gb)
>      has_partial = 0;
>      bit         = get_bits1(gb);
>      for (i = 0; i < s->yuv_macroblock_count; i += current_run) {
> +        if (get_bits_left(gb) <= 0)
> +            return AVERROR_INVALIDDATA;
>          current_run = vp4_get_mb_count(s, gb);
>          if (current_run > s->yuv_macroblock_count - i)
>              return -1;
> @@ -719,6 +721,8 @@ static int vp4_unpack_macroblocks(Vp3DecodeContext *s, GetBitContext *gb)
>      }
>  
>      if (has_partial) {
> +        if (get_bits_left(gb) <= 0)
> +            return AVERROR_INVALIDDATA;
>          bit  = get_bits1(gb);
>          current_run = vp4_get_mb_count(s, gb);
>          for (i = 0; i < s->yuv_macroblock_count; i++) {
> -- 
> 2.23.0

approve.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
Michael Niedermayer Sept. 2, 2019, 3:56 p.m. UTC | #2
On Mon, Sep 02, 2019 at 06:33:43PM +1000, Peter Ross wrote:
> On Sun, Sep 01, 2019 at 11:10:25PM +0200, Michael Niedermayer wrote:
> > Fixes: Timeout (82sec -> 1sec)
> > Fixes: 16411/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-5166958151991296
> > 
> > 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 | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> > index 28ed0461c7..a2bd2ef07d 100644
> > --- a/libavcodec/vp3.c
> > +++ b/libavcodec/vp3.c
> > @@ -710,6 +710,8 @@ static int vp4_unpack_macroblocks(Vp3DecodeContext *s, GetBitContext *gb)
> >      has_partial = 0;
> >      bit         = get_bits1(gb);
> >      for (i = 0; i < s->yuv_macroblock_count; i += current_run) {
> > +        if (get_bits_left(gb) <= 0)
> > +            return AVERROR_INVALIDDATA;
> >          current_run = vp4_get_mb_count(s, gb);
> >          if (current_run > s->yuv_macroblock_count - i)
> >              return -1;
> > @@ -719,6 +721,8 @@ static int vp4_unpack_macroblocks(Vp3DecodeContext *s, GetBitContext *gb)
> >      }
> >  
> >      if (has_partial) {
> > +        if (get_bits_left(gb) <= 0)
> > +            return AVERROR_INVALIDDATA;
> >          bit  = get_bits1(gb);
> >          current_run = vp4_get_mb_count(s, gb);
> >          for (i = 0; i < s->yuv_macroblock_count; i++) {
> > -- 
> > 2.23.0
> 
> approve.

will apply

thx

[...]
diff mbox

Patch

diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 28ed0461c7..a2bd2ef07d 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -710,6 +710,8 @@  static int vp4_unpack_macroblocks(Vp3DecodeContext *s, GetBitContext *gb)
     has_partial = 0;
     bit         = get_bits1(gb);
     for (i = 0; i < s->yuv_macroblock_count; i += current_run) {
+        if (get_bits_left(gb) <= 0)
+            return AVERROR_INVALIDDATA;
         current_run = vp4_get_mb_count(s, gb);
         if (current_run > s->yuv_macroblock_count - i)
             return -1;
@@ -719,6 +721,8 @@  static int vp4_unpack_macroblocks(Vp3DecodeContext *s, GetBitContext *gb)
     }
 
     if (has_partial) {
+        if (get_bits_left(gb) <= 0)
+            return AVERROR_INVALIDDATA;
         bit  = get_bits1(gb);
         current_run = vp4_get_mb_count(s, gb);
         for (i = 0; i < s->yuv_macroblock_count; i++) {