[FFmpeg-devel,3/3] avcodec/dirac_dwt_template: Fix Integer overflow in horizontal_compose_dd137i()

Submitted by Michael Niedermayer on Feb. 17, 2018, 9:25 p.m.

Details

Message ID 20180217212512.18487-3-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Feb. 17, 2018, 9:25 p.m.
Fixes: 5894/clusterfuzz-testcase-minimized-5315325420634112
Fixes: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'

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

Comments

Michael Niedermayer Feb. 18, 2018, 10:25 p.m.
On Sat, Feb 17, 2018 at 10:25:12PM +0100, Michael Niedermayer wrote:
> Fixes: 5894/clusterfuzz-testcase-minimized-5315325420634112
> Fixes: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/dirac_dwt_template.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply (without a bug and also covering horizontal_compose_dd97i)

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/dirac_dwt_template.c b/libavcodec/dirac_dwt_template.c
index e68cc4d530..19c008b988 100644
--- a/libavcodec/dirac_dwt_template.c
+++ b/libavcodec/dirac_dwt_template.c
@@ -118,8 +118,8 @@  static void RENAME(horizontal_compose_dd137i)(uint8_t *_b, uint8_t *_tmp, int w)
     tmp[w2+1] = tmp[w2] = tmp[w2-1];
 
     for (x = 0; x < w2; x++) {
-        b[2*x  ] = (tmp[x] + 1)>>1;
-        b[2*x+1] = (COMPOSE_DD97iH0(tmp[x-1], tmp[x], b[x+w2], tmp[x+1], tmp[x+2]) + 1)>>1;
+        b[2*x  ] = (tmp[x] + 1U)>>1;
+        b[2*x+1] = (COMPOSE_DD97iH0(tmp[x-1], tmp[x], b[x+w2], tmp[x+1], tmp[x+2]) + 1U)>>1;
     }
 }