diff mbox series

[FFmpeg-devel,2/5] avutil/timecode: Avoid undefined behavior with large framenum

Message ID 20201129000337.31514-2-michael@niedermayer.cc
State Accepted
Commit 1b1905739638c22b476c99c679b41f29fa00bf07
Headers show
Series [FFmpeg-devel,1/5] avformat/mov: Check a.size before computing next_root_atom
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Michael Niedermayer Nov. 29, 2020, 12:03 a.m. UTC
Fixes: signed integer overflow: 2147462079 + 2149596 cannot be represented in type 'int'
Fixes: 27565/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5091972813160448

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

Comments

Michael Niedermayer Jan. 18, 2021, 11:03 p.m. UTC | #1
On Sun, Nov 29, 2020 at 01:03:34AM +0100, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 2147462079 + 2149596 cannot be represented in type 'int'
> Fixes: 27565/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5091972813160448
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavutil/timecode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavutil/timecode.c b/libavutil/timecode.c
index f2db21c52c..9ac5c81677 100644
--- a/libavutil/timecode.c
+++ b/libavutil/timecode.c
@@ -49,7 +49,7 @@  int av_timecode_adjust_ntsc_framenum2(int framenum, int fps)
     d = framenum / frames_per_10mins;
     m = framenum % frames_per_10mins;
 
-    return framenum + 9 * drop_frames * d + drop_frames * ((m - drop_frames) / (frames_per_10mins / 10));
+    return framenum + 9U * drop_frames * d + drop_frames * ((m - drop_frames) / (frames_per_10mins / 10));
 }
 
 uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum)