[FFmpeg-cvslog] avcodec/dirac_dwt: Fix several integer overflows
Michael Niedermayer
git at videolan.org
Mon Feb 19 16:35:57 EET 2018
ffmpeg | branch: release/3.0 | Michael Niedermayer <michael at niedermayer.cc> | Thu Jan 25 23:14:37 2018 +0100| [35f47ac0d54b7591e8c390e47d209034b788d940] | committer: Michael Niedermayer
avcodec/dirac_dwt: Fix several integer overflows
Fixes: runtime error: signed integer overflow: -2146071175 + -268479557 cannot be represented in type 'int'
Fixes: 5237/clusterfuzz-testcase-minimized-4569895275593728
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit fe1e6c06d03432c3e9208f019533c1d701f485d0)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=35f47ac0d54b7591e8c390e47d209034b788d940
---
libavcodec/dirac_dwt.h | 4 ++--
libavcodec/dirac_dwt_template.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavcodec/dirac_dwt.h b/libavcodec/dirac_dwt.h
index 1af41e0702..68ebd19560 100644
--- a/libavcodec/dirac_dwt.h
+++ b/libavcodec/dirac_dwt.h
@@ -93,10 +93,10 @@ void ff_spatial_idwt_slice2(DWTContext *d, int y);
// shared stuff for simd optimizations
#define COMPOSE_53iL0(b0, b1, b2)\
- (b1 - ((int)(b0 + (unsigned)(b2) + 2) >> 2))
+ (b1 - (unsigned)((int)(b0 + (unsigned)(b2) + 2) >> 2))
#define COMPOSE_DIRAC53iH0(b0, b1, b2)\
- (b1 + ((int)(b0 + (unsigned)(b2) + 1) >> 1))
+ (b1 + (unsigned)((int)(b0 + (unsigned)(b2) + 1) >> 1))
#define COMPOSE_DD97iH0(b0, b1, b2, b3, b4)\
(int)(((unsigned)(b2) + ((int)(-b0 + 9U*b1 + 9U*b3 - b4 + 8) >> 4)))
diff --git a/libavcodec/dirac_dwt_template.c b/libavcodec/dirac_dwt_template.c
index e436c247a1..e68cc4d530 100644
--- a/libavcodec/dirac_dwt_template.c
+++ b/libavcodec/dirac_dwt_template.c
@@ -49,7 +49,7 @@ static void RENAME(vertical_compose53iL0)(uint8_t *_b0, uint8_t *_b1, uint8_t *_
TYPE *b1 = (TYPE *)_b1;
TYPE *b2 = (TYPE *)_b2;
for (i = 0; i < width; i++)
- b1[i] -= (int)(b0[i] + (unsigned)b2[i] + 2) >> 2;
+ b1[i] -= (unsigned)((int)(b0[i] + (unsigned)b2[i] + 2) >> 2);
}
static av_always_inline void RENAME(interleave)(TYPE *dst, TYPE *src0, TYPE *src1, int w2,
More information about the ffmpeg-cvslog
mailing list