diff mbox series

[FFmpeg-devel,2/6] avcodec/utils: fix 2 integer overflows in get_audio_frame_duration()

Message ID 20230618215021.3044-2-michael@niedermayer.cc
State Accepted
Commit a4bf559683a999c8faa408fdd8f29bd28a6a47ea
Headers show
Series [FFmpeg-devel,1/6] avformat/jpegxl_anim_dec: Perform operations in a different order | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer June 18, 2023, 9:50 p.m. UTC
Fixes: signed integer overflow: 256 * 668003712 cannot be represented in type 'int'
Fixes: 59819/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-4674636538052608

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

Comments

Michael Niedermayer June 22, 2023, 11:59 p.m. UTC | #1
On Sun, Jun 18, 2023 at 11:50:17PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 256 * 668003712 cannot be represented in type 'int'
> Fixes: 59819/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-4674636538052608
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/utils.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index a8514ba6c1..672eb15d98 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -641,9 +641,9 @@  static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba,
     if (sr > 0) {
         /* calc from sample rate */
         if (id == AV_CODEC_ID_TTA)
-            return 256 * sr / 245;
+            return 256ll * sr / 245;
         else if (id == AV_CODEC_ID_DST)
-            return 588 * sr / 44100;
+            return 588ll * sr / 44100;
         else if (id == AV_CODEC_ID_BINKAUDIO_DCT) {
             if (sr / 22050 > 22)
                 return 0;