diff mbox series

[FFmpeg-devel,7/7] avformat/sbgdec: Reduce the amount of floating point in str_to_time()

Message ID 20210116230729.30613-7-michael@niedermayer.cc
State Accepted
Commit ac6c8993f79eaefb76e1fdf0eef5373ab3a46a4e
Headers show
Series [FFmpeg-devel,1/7] avformat/mpsubdec: Use av_sat_add/sub64() in fracval handling
Related show

Checks

Context Check Description
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 Jan. 16, 2021, 11:07 p.m. UTC
Fixes: 1e+75 is outside the range of representable values of type 'long'
Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6626834808700928

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

Comments

Nicolas George Jan. 17, 2021, 2:52 p.m. UTC | #1
Michael Niedermayer (12021-01-17):
> Fixes: 1e+75 is outside the range of representable values of type 'long'
> Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6626834808700928
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/sbgdec.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Should be ok.

Regards,
Michael Niedermayer Jan. 18, 2021, 6:56 p.m. UTC | #2
On Sun, Jan 17, 2021 at 03:52:57PM +0100, Nicolas George wrote:
> Michael Niedermayer (12021-01-17):
> > Fixes: 1e+75 is outside the range of representable values of type 'long'
> > Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6626834808700928
> > 
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavformat/sbgdec.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> Should be ok.

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c
index f56eb9ff59..8672e2e976 100644
--- a/libavformat/sbgdec.c
+++ b/libavformat/sbgdec.c
@@ -181,6 +181,7 @@  static int str_to_time(const char *str, int64_t *rtime)
     char *end;
     int hours, minutes;
     double seconds = 0;
+    int64_t ts = 0;
 
     if (*cur < '0' || *cur > '9')
         return 0;
@@ -196,8 +197,9 @@  static int str_to_time(const char *str, int64_t *rtime)
         seconds = strtod(cur + 1, &end);
         if (end > cur + 1)
             cur = end;
+        ts = av_clipd(seconds * AV_TIME_BASE, INT64_MIN/2, INT64_MAX/2);
     }
-    *rtime = (hours * 3600LL + minutes * 60LL + seconds) * AV_TIME_BASE;
+    *rtime = (hours * 3600LL + minutes * 60LL) * AV_TIME_BASE + ts;
     return cur - str;
 }