avcodec/mdec: Fix signed integer overflow: 28835400 * 83 cannot be represented in...
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 5 May 2017 20:17:59 +0000 (22:17 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 5 May 2017 22:33:19 +0000 (00:33 +0200)
Fixes: 1346/clusterfuzz-testcase-minimized-5776732600664064

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/mdec.c

index 42bd561..8e28aa0 100644 (file)
@@ -111,11 +111,11 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n)
                 j = scantable[i];
                 if (level < 0) {
                     level = -level;
-                    level = (level * qscale * quant_matrix[j]) >> 3;
+                    level = (level * (unsigned)qscale * quant_matrix[j]) >> 3;
                     level = (level - 1) | 1;
                     level = -level;
                 } else {
-                    level = (level * qscale * quant_matrix[j]) >> 3;
+                    level = (level * (unsigned)qscale * quant_matrix[j]) >> 3;
                     level = (level - 1) | 1;
                 }
             }