diff mbox series

[FFmpeg-devel,2/2] avcodec/adpcm: Fix integer overflow in ADPCM THP

Message ID 20200212220319.4802-2-michael@niedermayer.cc
State Accepted
Commit b12b05374f7025167e2c43449ceb8ba3f0a6083f
Headers show
Series [FFmpeg-devel,1/2] avcodec/midivid: Check dimensions to be the multiple assumed by the implementation | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Michael Niedermayer Feb. 12, 2020, 10:03 p.m. UTC
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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer May 12, 2020, 11:07 p.m. UTC | #1
On Wed, Feb 12, 2020 at 11:03:19PM +0100, Michael Niedermayer wrote:
> 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 | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply


[...]
diff mbox series

Patch

diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 0cd28431d7..3728279525 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -1698,8 +1698,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++) {