diff mbox series

[FFmpeg-devel] avutil/timecode: Avoid fps overflow

Message ID 20210301143209.29584-1-michael@niedermayer.cc
State Accepted
Commit c94875471e3ba3dc396c6919ff3ec9b14539cd71
Headers show
Series [FFmpeg-devel] avutil/timecode: Avoid fps overflow
Related show

Checks

Context Check Description
andriy/x86_make_warn warning New warnings during build
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer March 1, 2021, 2:32 p.m. UTC
Fixes: Integer overflow and division by 0
Fixes: poc-202102-div.mov

Found-by: 1vanChen of NSFOCUS Security Team
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavutil/timecode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer March 14, 2021, 10:12 p.m. UTC | #1
On Mon, Mar 01, 2021 at 03:32:09PM +0100, Michael Niedermayer wrote:
> Fixes: Integer overflow and division by 0
> Fixes: poc-202102-div.mov
> 
> Found-by: 1vanChen of NSFOCUS Security Team
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavutil/timecode.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavutil/timecode.c b/libavutil/timecode.c
index b1b504edbf..2fc3295e25 100644
--- a/libavutil/timecode.c
+++ b/libavutil/timecode.c
@@ -114,8 +114,8 @@  char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum)
     }
     ff = framenum % fps;
     ss = framenum / fps        % 60;
-    mm = framenum / (fps*60)   % 60;
-    hh = framenum / (fps*3600);
+    mm = framenum / (fps*60LL) % 60;
+    hh = framenum / (fps*3600LL);
     if (tc->flags & AV_TIMECODE_FLAG_24HOURSMAX)
         hh = hh % 24;
     snprintf(buf, AV_TIMECODE_STR_SIZE, "%s%02d:%02d:%02d%c%02d",