diff mbox

[FFmpeg-devel,2/3] avcodec/h264idct_template: Fix integer overflows in ff_h264_idct8_add()

Message ID 20171104001921.24006-2-michael@niedermayer.cc
State Accepted
Commit e131b8cedb00043dcc97cc05ca04749ec8ff57de
Headers show

Commit Message

Michael Niedermayer Nov. 4, 2017, 12:19 a.m. UTC
Fixes: runtime error: signed integer overflow: -503316480 + -2013265038 cannot be represented in type 'int'
Fixes: 3805/clusterfuzz-testcase-minimized-6578427831255040

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

Comments

Michael Niedermayer Nov. 5, 2017, 8:32 p.m. UTC | #1
On Sat, Nov 04, 2017 at 01:19:20AM +0100, Michael Niedermayer wrote:
> Fixes: runtime error: signed integer overflow: -503316480 + -2013265038 cannot be represented in type 'int'
> Fixes: 3805/clusterfuzz-testcase-minimized-6578427831255040
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/h264idct_template.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

will apply

[...]
diff mbox

Patch

diff --git a/libavcodec/h264idct_template.c b/libavcodec/h264idct_template.c
index fbd07cb8d5..7526bdd812 100644
--- a/libavcodec/h264idct_template.c
+++ b/libavcodec/h264idct_template.c
@@ -91,10 +91,10 @@  void FUNCC(ff_h264_idct8_add)(uint8_t *_dst, int16_t *_block, int stride){
         const int a5 = -block[i+1*8] + (unsigned)block[i+7*8] + block[i+5*8] + (block[i+5*8]>>1);
         const int a7 =  block[i+3*8] + (unsigned)block[i+5*8] + block[i+1*8] + (block[i+1*8]>>1);
 
-        const int b1 = (a7>>2) + a1;
-        const int b3 =  a3 + (a5>>2);
-        const int b5 = (a3>>2) - a5;
-        const int b7 =  a7 - (a1>>2);
+        const int b1 = (a7>>2) + (unsigned)a1;
+        const int b3 =  (unsigned)a3 + (a5>>2);
+        const int b5 = (a3>>2) - (unsigned)a5;
+        const int b7 =  (unsigned)a7 - (a1>>2);
 
         block[i+0*8] = b0 + b7;
         block[i+7*8] = b0 - b7;