[FFmpeg-cvslog] avcodec/vp7: Check for end of input in vp78_decode_mv_mb_modes()
Michael Niedermayer
git at videolan.org
Sun Dec 16 11:18:50 EET 2018
ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sat Dec 15 01:53:16 2018 +0100| [b11b3d2585cda24e60160070f10f5d70a8c42fbf] | committer: Michael Niedermayer
avcodec/vp7: Check for end of input in vp78_decode_mv_mb_modes()
Fixes: Timeout
Fixes: 10313/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP7_fuzzer-5637719389110272
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross at xvid.org>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b11b3d2585cda24e60160070f10f5d70a8c42fbf
---
libavcodec/vp8.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c
index a06692c476..ba79e5fdab 100644
--- a/libavcodec/vp8.c
+++ b/libavcodec/vp8.c
@@ -2268,7 +2268,7 @@ void filter_mb_simple(VP8Context *s, uint8_t *dst, VP8FilterStrength *f,
#define MARGIN (16 << 2)
static av_always_inline
-void vp78_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe,
+int vp78_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe,
VP8Frame *prev_frame, int is_vp7)
{
VP8Context *s = avctx->priv_data;
@@ -2285,6 +2285,10 @@ void vp78_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe,
s->mv_bounds.mv_min.x = -MARGIN;
s->mv_bounds.mv_max.x = ((s->mb_width - 1) << 6) + MARGIN;
+
+ if (vpX_rac_is_end(&s->c)) {
+ return AVERROR_INVALIDDATA;
+ }
for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) {
if (mb_y == 0)
AV_WN32A((mb - s->mb_width - 1)->intra4x4_pred_mode_top,
@@ -2298,18 +2302,19 @@ void vp78_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *curframe,
s->mv_bounds.mv_min.y -= 64;
s->mv_bounds.mv_max.y -= 64;
}
+ return 0;
}
-static void vp7_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame,
+static int vp7_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame,
VP8Frame *prev_frame)
{
- vp78_decode_mv_mb_modes(avctx, cur_frame, prev_frame, IS_VP7);
+ return vp78_decode_mv_mb_modes(avctx, cur_frame, prev_frame, IS_VP7);
}
-static void vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame,
+static int vp8_decode_mv_mb_modes(AVCodecContext *avctx, VP8Frame *cur_frame,
VP8Frame *prev_frame)
{
- vp78_decode_mv_mb_modes(avctx, cur_frame, prev_frame, IS_VP8);
+ return vp78_decode_mv_mb_modes(avctx, cur_frame, prev_frame, IS_VP8);
}
#if HAVE_THREADS
@@ -2744,9 +2749,11 @@ int vp78_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
!s->segmentation.update_map)
ff_thread_await_progress(&prev_frame->tf, 1, 0);
if (is_vp7)
- vp7_decode_mv_mb_modes(avctx, curframe, prev_frame);
+ ret = vp7_decode_mv_mb_modes(avctx, curframe, prev_frame);
else
- vp8_decode_mv_mb_modes(avctx, curframe, prev_frame);
+ ret = vp8_decode_mv_mb_modes(avctx, curframe, prev_frame);
+ if (ret < 0)
+ goto err;
}
if (avctx->active_thread_type == FF_THREAD_FRAME)
More information about the ffmpeg-cvslog
mailing list