[FFmpeg-cvslog] avformat/timecode: use 64bit for intermediate for rounding in fps_from_frame_rate()

Michael Niedermayer git at videolan.org
Sun Apr 14 21:33:35 EEST 2024


ffmpeg | branch: release/4.4 | Michael Niedermayer <michael at niedermayer.cc> | Tue Mar 26 00:27:39 2024 +0100| [0ba64f10421ca08f24bba6975d69c5461a5cb610] | committer: Michael Niedermayer

avformat/timecode: use 64bit for intermediate for rounding in fps_from_frame_rate()

Fixes: 62276/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4802790784303104
Fixes: signed integer overflow: 1768972133 + 968491058 cannot be represented in type 'int'

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 3d8d778a68531b406455f8090d81216ef374ab75)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0ba64f10421ca08f24bba6975d69c5461a5cb610
---

 libavutil/timecode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/timecode.c b/libavutil/timecode.c
index 2fc3295e25..af21d88e11 100644
--- a/libavutil/timecode.c
+++ b/libavutil/timecode.c
@@ -208,7 +208,7 @@ static int fps_from_frame_rate(AVRational rate)
 {
     if (!rate.den || !rate.num)
         return -1;
-    return (rate.num + rate.den/2) / rate.den;
+    return (rate.num + rate.den/2LL) / rate.den;
 }
 
 int av_timecode_check_frame_rate(AVRational rate)



More information about the ffmpeg-cvslog mailing list