]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/snowdec: Sanity check hcoeff
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 6 Aug 2020 19:35:06 +0000 (21:35 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 7 Aug 2020 12:01:00 +0000 (14:01 +0200)
Fixes: signed integer overflow: -2147483648 * -1 cannot be represented in type 'int'
Fixes: 24011/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SNOW_fuzzer-5486376610168832
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/snowdec.c

index 88664dc472bd2a6afda196fca07f9f702b5561b4..5e69f39022df3de2d34e030e9557043b33b55153 100644 (file)
@@ -369,7 +369,10 @@ static int decode_header(SnowContext *s){
                 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));
+                    unsigned hcoeff = get_symbol(&s->c, s->header_state, 0);
+                    if (hcoeff > 127)
+                        return AVERROR_INVALIDDATA;
+                    p->hcoeff[i]= hcoeff * (1-2*(i&1));
                     sum += p->hcoeff[i];
                 }
                 p->hcoeff[0]= 32-sum;