[FFmpeg-cvslog] truemotion2: check motion vectors for validity

Michael Niedermayer git at videolan.org
Sun Mar 4 07:32:26 CET 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Mar  4 07:09:00 2012 +0100| [2b693546ad3a8ac16bdce0b9483dc8ae7b3fdb95] | committer: Michael Niedermayer

truemotion2: check motion vectors for validity

Fixes out of array read

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2b693546ad3a8ac16bdce0b9483dc8ae7b3fdb95
---

 libavcodec/truemotion2.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
index ead7a39..1ccac32 100644
--- a/libavcodec/truemotion2.c
+++ b/libavcodec/truemotion2.c
@@ -638,6 +638,11 @@ static inline void tm2_motion_block(TM2Context *ctx, AVFrame *pic, int bx, int b
     mx = GET_TOK(ctx, TM2_MOT);
     my = GET_TOK(ctx, TM2_MOT);
 
+    if (4*bx+mx<0 || 4*by+my<0 || 4*bx+mx+4 > ctx->avctx->width || 4*by+my+4 > ctx->avctx->height) {
+        av_log(0,0, "MV out of picture\n");
+        return;
+    }
+
     Yo += my * oYstride + mx;
     Uo += (my >> 1) * oUstride + (mx >> 1);
     Vo += (my >> 1) * oVstride + (mx >> 1);



More information about the ffmpeg-cvslog mailing list