[FFmpeg-devel,1/5] avcodec/vp8: do vp7_fade_frame() later

Submitted by Michael Niedermayer on Aug. 1, 2019, 9:44 p.m.

Details

Message ID 20190801214443.7695-1-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Aug. 1, 2019, 9:44 p.m.
Fixes: Timeout (100sec -> 5sec)
Fixes: 15073/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP7_fuzzer-5649257362620416

Untested as none of the vp7 samples i found executes this codepath

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

Comments

Peter Ross Aug. 2, 2019, 12:46 p.m.
On Thu, Aug 01, 2019 at 11:44:39PM +0200, Michael Niedermayer wrote:
> Fixes: Timeout (100sec -> 5sec)
> Fixes: 15073/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP7_fuzzer-5649257362620416
> 
> Untested as none of the vp7 samples i found executes this codepath

see attached. its all i can find :(

> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/vp8.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
> index ba79e5fdab..efc62aabaf 100644
> --- a/libavcodec/vp8.c
> +++ b/libavcodec/vp8.c
> @@ -501,15 +501,10 @@ static void fade(uint8_t *dst, ptrdiff_t dst_linesize,
>      }
>  }
>  
> -static int vp7_fade_frame(VP8Context *s, VP56RangeCoder *c)
> +static int vp7_fade_frame(VP8Context *s, int alpha, int beta)
>  {
> -    int alpha = (int8_t) vp8_rac_get_uint(c, 8);
> -    int beta  = (int8_t) vp8_rac_get_uint(c, 8);
>      int ret;
>  
> -    if (c->end <= c->buffer && c->bits >= 0)
> -        return AVERROR_INVALIDDATA;
> -
>      if (!s->keyframe && (alpha || beta)) {
>          int width  = s->mb_width * 16;
>          int height = s->mb_height * 16;
> @@ -549,6 +544,8 @@ static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
>      int part1_size, hscale, vscale, i, j, ret;
>      int width  = s->avctx->width;
>      int height = s->avctx->height;
> +    int alpha = 0;
> +    int beta  = 0;
>  
>      if (buf_size < 4) {
>          return AVERROR_INVALIDDATA;
> @@ -665,8 +662,8 @@ static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
>          return AVERROR_INVALIDDATA;
>      /* E. Fading information for previous frame */
>      if (s->fade_present && vp8_rac_get(c)) {
> -        if ((ret = vp7_fade_frame(s ,c)) < 0)
> -            return ret;
> +        alpha = (int8_t) vp8_rac_get_uint(c, 8);
> +        beta  = (int8_t) vp8_rac_get_uint(c, 8);
>      }
>  
>      /* F. Loop filter type */
> @@ -696,6 +693,12 @@ static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
>          vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP7_MVC_SIZE);
>      }
>  
> +    if (c->end <= c->buffer && c->bits >= 0)
> +        return AVERROR_INVALIDDATA;
> +
> +    if ((ret = vp7_fade_frame(s, alpha, beta)) < 0)
> +        return ret;
> +
>      return 0;
>  }
>  
> -- 
> 2.22.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".
-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)

Patch hide | download patch | download mbox

diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index ba79e5fdab..efc62aabaf 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -501,15 +501,10 @@  static void fade(uint8_t *dst, ptrdiff_t dst_linesize,
     }
 }
 
-static int vp7_fade_frame(VP8Context *s, VP56RangeCoder *c)
+static int vp7_fade_frame(VP8Context *s, int alpha, int beta)
 {
-    int alpha = (int8_t) vp8_rac_get_uint(c, 8);
-    int beta  = (int8_t) vp8_rac_get_uint(c, 8);
     int ret;
 
-    if (c->end <= c->buffer && c->bits >= 0)
-        return AVERROR_INVALIDDATA;
-
     if (!s->keyframe && (alpha || beta)) {
         int width  = s->mb_width * 16;
         int height = s->mb_height * 16;
@@ -549,6 +544,8 @@  static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
     int part1_size, hscale, vscale, i, j, ret;
     int width  = s->avctx->width;
     int height = s->avctx->height;
+    int alpha = 0;
+    int beta  = 0;
 
     if (buf_size < 4) {
         return AVERROR_INVALIDDATA;
@@ -665,8 +662,8 @@  static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
         return AVERROR_INVALIDDATA;
     /* E. Fading information for previous frame */
     if (s->fade_present && vp8_rac_get(c)) {
-        if ((ret = vp7_fade_frame(s ,c)) < 0)
-            return ret;
+        alpha = (int8_t) vp8_rac_get_uint(c, 8);
+        beta  = (int8_t) vp8_rac_get_uint(c, 8);
     }
 
     /* F. Loop filter type */
@@ -696,6 +693,12 @@  static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_si
         vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP7_MVC_SIZE);
     }
 
+    if (c->end <= c->buffer && c->bits >= 0)
+        return AVERROR_INVALIDDATA;
+
+    if ((ret = vp7_fade_frame(s, alpha, beta)) < 0)
+        return ret;
+
     return 0;
 }