diff mbox

[FFmpeg-devel,1/3] avcodec/vp3: Do not initialize unused tables for keyframes in unpack_superblock()

Message ID 20181028140459.4844-1-michael@niedermayer.cc
State Accepted
Commit 88e3807aafd3ed50f3963c477fa92495491793e2
Headers show

Commit Message

Michael Niedermayer Oct. 28, 2018, 2:04 p.m. UTC
Fixes: Timeout (139sec -> 102sec)
Fixes: 9642/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-6676767875006464

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

Comments

James Almer Oct. 28, 2018, 2:15 p.m. UTC | #1
On 10/28/2018 11:04 AM, Michael Niedermayer wrote:
> Fixes: Timeout (139sec -> 102sec)
> Fixes: 9642/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-6676767875006464
> 
> 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 | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> index 0e6da89abb..348416b25d 100644
> --- a/libavcodec/vp3.c
> +++ b/libavcodec/vp3.c
> @@ -544,8 +544,21 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
>                                           : s->y_superblock_count);
>          int num_coded_frags = 0;
>  
> +        if (s->keyframe) {
> +            for (i = sb_start; i < sb_end; i++) {
> +                /* iterate through all 16 fragments in a superblock */
> +                for (j = 0; j < 16; j++) {
> +                    /* if the fragment is in bounds, check its coding status */
> +                    current_fragment = s->superblock_fragments[i * 16 + j];
> +                    if (current_fragment != -1) {
> +                        s->coded_fragment_list[plane][num_coded_frags++] =
> +                            current_fragment;
> +                    }
> +                }
> +            }
> +        } else {
>          for (i = sb_start; i < sb_end && get_bits_left(gb) > 0; i++) {
> -            if (s->keyframe == 0 && get_bits_left(gb) < plane0_num_coded_frags >> 2) {
> +            if (get_bits_left(gb) < plane0_num_coded_frags >> 2) {
>                  return AVERROR_INVALIDDATA;
>              }
>              /* iterate through all 16 fragments in a superblock */
> @@ -580,6 +593,7 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
>                  }
>              }
>          }
> +        }
>          if (!plane)
>              plane0_num_coded_frags = num_coded_frags;
>          s->total_num_coded_frags += num_coded_frags;

Please reindent before you push, either as a separate commit or directly
in this one.
Michael Niedermayer Oct. 29, 2018, 3:24 p.m. UTC | #2
On Sun, Oct 28, 2018 at 11:15:08AM -0300, James Almer wrote:
> On 10/28/2018 11:04 AM, Michael Niedermayer wrote:
> > Fixes: Timeout (139sec -> 102sec)
> > Fixes: 9642/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP3_fuzzer-6676767875006464
> > 
> > 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 | 16 +++++++++++++++-
> >  1 file changed, 15 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
> > index 0e6da89abb..348416b25d 100644
> > --- a/libavcodec/vp3.c
> > +++ b/libavcodec/vp3.c
> > @@ -544,8 +544,21 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
> >                                           : s->y_superblock_count);
> >          int num_coded_frags = 0;
> >  
> > +        if (s->keyframe) {
> > +            for (i = sb_start; i < sb_end; i++) {
> > +                /* iterate through all 16 fragments in a superblock */
> > +                for (j = 0; j < 16; j++) {
> > +                    /* if the fragment is in bounds, check its coding status */
> > +                    current_fragment = s->superblock_fragments[i * 16 + j];
> > +                    if (current_fragment != -1) {
> > +                        s->coded_fragment_list[plane][num_coded_frags++] =
> > +                            current_fragment;
> > +                    }
> > +                }
> > +            }
> > +        } else {
> >          for (i = sb_start; i < sb_end && get_bits_left(gb) > 0; i++) {
> > -            if (s->keyframe == 0 && get_bits_left(gb) < plane0_num_coded_frags >> 2) {
> > +            if (get_bits_left(gb) < plane0_num_coded_frags >> 2) {
> >                  return AVERROR_INVALIDDATA;
> >              }
> >              /* iterate through all 16 fragments in a superblock */
> > @@ -580,6 +593,7 @@ static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
> >                  }
> >              }
> >          }
> > +        }
> >          if (!plane)
> >              plane0_num_coded_frags = num_coded_frags;
> >          s->total_num_coded_frags += num_coded_frags;
> 
> Please reindent before you push, either as a separate commit or directly
> in this one.

will add a commit that reindents
will apply

thanks
[...]
diff mbox

Patch

diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
index 0e6da89abb..348416b25d 100644
--- a/libavcodec/vp3.c
+++ b/libavcodec/vp3.c
@@ -544,8 +544,21 @@  static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
                                          : s->y_superblock_count);
         int num_coded_frags = 0;
 
+        if (s->keyframe) {
+            for (i = sb_start; i < sb_end; i++) {
+                /* iterate through all 16 fragments in a superblock */
+                for (j = 0; j < 16; j++) {
+                    /* if the fragment is in bounds, check its coding status */
+                    current_fragment = s->superblock_fragments[i * 16 + j];
+                    if (current_fragment != -1) {
+                        s->coded_fragment_list[plane][num_coded_frags++] =
+                            current_fragment;
+                    }
+                }
+            }
+        } else {
         for (i = sb_start; i < sb_end && get_bits_left(gb) > 0; i++) {
-            if (s->keyframe == 0 && get_bits_left(gb) < plane0_num_coded_frags >> 2) {
+            if (get_bits_left(gb) < plane0_num_coded_frags >> 2) {
                 return AVERROR_INVALIDDATA;
             }
             /* iterate through all 16 fragments in a superblock */
@@ -580,6 +593,7 @@  static int unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb)
                 }
             }
         }
+        }
         if (!plane)
             plane0_num_coded_frags = num_coded_frags;
         s->total_num_coded_frags += num_coded_frags;