Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-04-10 21:32:55 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2021-10-06 14:54:16 +0300
commit5ca2f59b8989e8c80fa86d357e4249a923898d0d (patch)
treee1d4c82173d6261b8d0eca5137a555d11e433e51
parent8620139042170768352d615d365ec2275135bbb5 (diff)
avcodec/utils: Check ima wav duration for overflow
Fixes: signed integer overflow: 44331634 * 65 cannot be represented in type 'int' Fixes: 32120/clusterfuzz-testcase-minimized-ffmpeg_dem_RSD_fuzzer-5760221223583744 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 f40e9b13554d88cbdd6cd2b4a3da2cbea9590f5d) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/utils.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 47a76ef6d0..25f1271734 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1700,11 +1700,15 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba,
if (ba > 0) {
/* calc from frame_bytes, channels, and block_align */
int blocks = frame_bytes / ba;
+ int64_t tmp;
switch (id) {
case AV_CODEC_ID_ADPCM_IMA_WAV:
if (bps < 2 || bps > 5)
return 0;
- return blocks * (1 + (ba - 4 * ch) / (bps * ch) * 8);
+ tmp = blocks * (1LL + (ba - 4 * ch) / (bps * ch) * 8);
+ if (tmp != (int)tmp)
+ return 0;
+ return tmp;
case AV_CODEC_ID_ADPCM_IMA_DK3:
return blocks * (((ba - 16) * 2 / 3 * 4) / ch);
case AV_CODEC_ID_ADPCM_IMA_DK4: