]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/adpcm: Fix integer overflow in ADPCM THP
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 12 Feb 2020 20:30:08 +0000 (21:30 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 13 May 2020 07:03:45 +0000 (09:03 +0200)
The reference (thp.txt) uses floats so wrap around would seem incorrect.

Fixes: signed integer overflow: 1073741824 + 1073741824 cannot be represented in type 'int'
Fixes: 20658/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_THP_fuzzer-5646302555930624
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/adpcm.c

index 846ec5ef9c37c64b42dac5411eef3f98dbd249c5..dc4a9222afc804ff526b18c19574e95b177b701c 100644 (file)
@@ -1853,8 +1853,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
                 int byte = bytestream2_get_byteu(&gb);
                 int index = (byte >> 4) & 7;
                 unsigned int exp = byte & 0x0F;
-                int factor1 = table[ch][index * 2];
-                int factor2 = table[ch][index * 2 + 1];
+                int64_t factor1 = table[ch][index * 2];
+                int64_t factor2 = table[ch][index * 2 + 1];
 
                 /* Decode 14 samples.  */
                 for (n = 0; n < 14 && (i * 14 + n < nb_samples); n++) {