diff mbox series

[FFmpeg-devel] avcodec/mv30: Do not allow MVs outside the allocated image

Message ID 20200520205101.2438-1-michael@niedermayer.cc
State Accepted
Commit e73a25168028fea7ca8a837519c6643875c09cab
Headers show
Series [FFmpeg-devel] avcodec/mv30: Do not allow MVs outside the allocated image
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Michael Niedermayer May 20, 2020, 8:51 p.m. UTC
Fixes: out of array read
Fixes: 21804/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MV30_fuzzer-5673678898724864

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

Comments

Michael Niedermayer June 4, 2020, 10:04 p.m. UTC | #1
On Wed, May 20, 2020 at 10:51:01PM +0200, Michael Niedermayer wrote:
> Fixes: out of array read
> Fixes: 21804/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MV30_fuzzer-5673678898724864
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/mv30.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavcodec/mv30.c b/libavcodec/mv30.c
index 7e67133cf7d..658f32c6ff6 100644
--- a/libavcodec/mv30.c
+++ b/libavcodec/mv30.c
@@ -545,8 +545,8 @@  static int decode_inter(AVCodecContext *avctx, GetBitContext *gb,
                 int px = x + mv_x;
                 int py = y + mv_y;
 
-                if (px < 0 || px >= avctx->width ||
-                    py < 0 || py >= avctx->height)
+                if (px < 0 || px > FFALIGN(avctx->width , 16) - 16 ||
+                    py < 0 || py > FFALIGN(avctx->height, 16) - 16)
                     return AVERROR_INVALIDDATA;
 
                 src[0] = prev->data[0] + in_linesize[0] * py + px;