diff mbox

[FFmpeg-devel] avcodec/h264idct_template: Fix integer overflow in ff_h264_idct8_add

Message ID 20171120135815.20251-1-michael@niedermayer.cc
State Accepted
Commit 9cc926da7d9920d17b76584e7212309ab5c02387
Headers show

Commit Message

Michael Niedermayer Nov. 20, 2017, 1:58 p.m. UTC
Fixes: signed integer overflow: 452986184 - -2113885312 cannot be represented in type 'int'
Fixes: 4196/clusterfuzz-testcase-minimized-5580648594014208

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. 26, 2017, 11:53 p.m. UTC | #1
On Mon, Nov 20, 2017 at 02:58:15PM +0100, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 452986184 - -2113885312 cannot be represented in type 'int'
> Fixes: 4196/clusterfuzz-testcase-minimized-5580648594014208
> 
> 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(-)

applied

[...]
diff mbox

Patch

diff --git a/libavcodec/h264idct_template.c b/libavcodec/h264idct_template.c
index 7526bdd812..5993ae2e6e 100644
--- a/libavcodec/h264idct_template.c
+++ b/libavcodec/h264idct_template.c
@@ -76,10 +76,10 @@  void FUNCC(ff_h264_idct8_add)(uint8_t *_dst, int16_t *_block, int stride){
 
     for( i = 0; i < 8; i++ )
     {
-        const unsigned int a0 =  block[i+0*8] + block[i+4*8];
-        const unsigned int a2 =  block[i+0*8] - block[i+4*8];
-        const unsigned int a4 = (block[i+2*8]>>1) - block[i+6*8];
-        const unsigned int a6 = (block[i+6*8]>>1) + block[i+2*8];
+        const unsigned int a0 =  block[i+0*8] + (unsigned)block[i+4*8];
+        const unsigned int a2 =  block[i+0*8] - (unsigned)block[i+4*8];
+        const unsigned int a4 = (block[i+2*8]>>1) - (unsigned)block[i+6*8];
+        const unsigned int a6 = (block[i+6*8]>>1) + (unsigned)block[i+2*8];
 
         const unsigned int b0 = a0 + a6;
         const unsigned int b2 = a2 + a4;