aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-01-15 03:03:36 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2018-02-19 02:40:54 +0100
commitdfb84488428bae5fe3aacecdb06f934c607a7e44 (patch)
tree4d995b6e0a6eb9487e160d9b1d797a01f19adb04
parente5296dfffaad9e8c61db88d6862c23cae08e35bc (diff)
downloadffmpeg-dfb84488428bae5fe3aacecdb06f934c607a7e44.tar.gz
avcodec/snowdec: Fix integer overflow before htaps check
Fixes: runtime error: signed integer overflow: -1094995529 * 2 cannot be represented in type 'int' Fixes: 4828/clusterfuzz-testcase-minimized-5100849937252352 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 2eecf3cf8eeae67697934df326e98df2149881e5) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/snowdec.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libavcodec/snowdec.c b/libavcodec/snowdec.c
index df425b8cf3..00fa064102 100644
--- a/libavcodec/snowdec.c
+++ b/libavcodec/snowdec.c
@@ -363,9 +363,10 @@ static int decode_header(SnowContext *s){
int htaps, i, sum=0;
Plane *p= &s->plane[plane_index];
p->diag_mc= get_rac(&s->c, s->header_state);
- htaps= get_symbol(&s->c, s->header_state, 0)*2 + 2;
- if((unsigned)htaps >= HTAPS_MAX || htaps==0)
+ htaps= get_symbol(&s->c, s->header_state, 0);
+ if((unsigned)htaps >= HTAPS_MAX/2 - 1)
return AVERROR_INVALIDDATA;
+ htaps = htaps*2 + 2;
p->htaps= htaps;
for(i= htaps/2; i; i--){
p->hcoeff[i]= get_symbol(&s->c, s->header_state, 0) * (1-2*(i&1));