[FFmpeg-cvslog] avcodec/rv34: Fix runtime error: signed integer overflow: 768 * 4126720 cannot be represented in type 'int'

Michael Niedermayer git at videolan.org
Wed May 17 18:38:45 EEST 2017


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Wed May 17 16:33:16 2017 +0200| [4bd869eb7c8416942f12b61db6439d2bfc474456] | committer: Michael Niedermayer

avcodec/rv34: Fix runtime error: signed integer overflow: 768 * 4126720 cannot be represented in type 'int'

Fixes: 1655/clusterfuzz-testcase-minimized-5587079276789760

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavcodec/rv34.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index d2d676a86d..f1495fb5a8 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -521,7 +521,7 @@ static int calc_add_mv(RV34DecContext *r, int dir, int val)
 {
     int mul = dir ? -r->mv_weight2 : r->mv_weight1;
 
-    return (val * mul + 0x2000) >> 14;
+    return (int)(val * (SUINT)mul + 0x2000) >> 14;
 }
 
 /**
@@ -1762,6 +1762,9 @@ int ff_rv34_decode_frame(AVCodecContext *avctx,
                 r->mv_weight1 = r->mv_weight2 = r->weight1 = r->weight2 = 8192;
                 r->scaled_weight = 0;
             }else{
+                if (FFMAX(dist0, dist1) > refdist)
+                    av_log(avctx, AV_LOG_TRACE, "distance overflow\n");
+
                 r->mv_weight1 = (dist0 << 14) / refdist;
                 r->mv_weight2 = (dist1 << 14) / refdist;
                 if((r->mv_weight1|r->mv_weight2) & 511){



More information about the ffmpeg-cvslog mailing list