[FFmpeg-devel,6/6] avcodec/takdec: Fix overflow with large sample rates

Submitted by Michael Niedermayer on Oct. 5, 2019, 9:41 p.m.

Details

Message ID 20191005214107.20093-6-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Oct. 5, 2019, 9:41 p.m.
Fixes: signed integer overflow: 2147483647 + 511 cannot be represented in type 'int'
Fixes: 17899/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TAK_fuzzer-5719753322135552

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/takdec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/takdec.c b/libavcodec/takdec.c
index 4fb5825532..8ec87ab509 100644
--- a/libavcodec/takdec.c
+++ b/libavcodec/takdec.c
@@ -176,8 +176,8 @@  static void set_sample_rate_params(AVCodecContext *avctx)
     } else {
         shift = 0;
     }
-    s->uval           = FFALIGN(avctx->sample_rate + 511 >> 9, 4) << shift;
-    s->subframe_scale = FFALIGN(avctx->sample_rate + 511 >> 9, 4) << 1;
+    s->uval           = FFALIGN(avctx->sample_rate + 511LL >> 9, 4) << shift;
+    s->subframe_scale = FFALIGN(avctx->sample_rate + 511LL >> 9, 4) << 1;
 }
 
 static av_cold int tak_decode_init(AVCodecContext *avctx)