aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-07-22 19:11:04 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2018-10-28 02:22:42 +0200
commit330ed0772c6f6f36e9a027757f393a2886e44c55 (patch)
tree7076c93f5e6d75cbd25809d4486aa89992d375d1
parent9da24737a3b27c962a4bba8d1b16acdff4a078f2 (diff)
downloadffmpeg-330ed0772c6f6f36e9a027757f393a2886e44c55.tar.gz
avcodec/dirac_dwt_template: Fix several integer overflows in horizontal_compose_daub97i()
Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int' Fixes: 8926/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DIRAC_fuzzer-6047609228623872 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 69cac9e130dc8c9d2a5b8012011df372974adf35) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/dirac_dwt_template.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libavcodec/dirac_dwt_template.c b/libavcodec/dirac_dwt_template.c
index 2369c8d15b..5d55d932a1 100644
--- a/libavcodec/dirac_dwt_template.c
+++ b/libavcodec/dirac_dwt_template.c
@@ -190,15 +190,15 @@ static void RENAME(horizontal_compose_daub97i)(uint8_t *_b, uint8_t *_temp, int
// second stage combined with interleave and shift
b0 = b2 = COMPOSE_DAUB97iL0(temp[w2], temp[0], temp[w2]);
- b[0] = (b0 + 1) >> 1;
+ b[0] = ~((~b0) >> 1);
for (x = 1; x < w2; x++) {
b2 = COMPOSE_DAUB97iL0(temp[x+w2-1], temp[x ], temp[x+w2]);
b1 = COMPOSE_DAUB97iH0( b0, temp[x+w2-1], b2 );
- b[2*x-1] = (b1 + 1) >> 1;
- b[2*x ] = (b2 + 1) >> 1;
+ b[2*x-1] = ~((~b1) >> 1);
+ b[2*x ] = ~((~b2) >> 1);
b0 = b2;
}
- b[w-1] = (COMPOSE_DAUB97iH0(b2, temp[w-1], b2) + 1) >> 1;
+ b[w-1] = ~((~COMPOSE_DAUB97iH0(b2, temp[w-1], b2)) >> 1);
}
static void RENAME(vertical_compose_dirac53iH0)(uint8_t *_b0, uint8_t *_b1, uint8_t *_b2,