diff mbox series

[FFmpeg-devel,11/11] avutil/mathematics: Use av_sat_add64() for the last addition in av_add_stable()

Message ID 20201020205619.7939-11-michael@niedermayer.cc
State Accepted
Commit ac8cebd48e405e6f610fc8e61f070f1258b73017
Headers show
Series [FFmpeg-devel,01/11] avcodec/notchlc: Check uncompressed size against input for LZ4
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 Oct. 20, 2020, 8:56 p.m. UTC
Fixes: signed integer overflow: 9223372036854770375 + 5450 cannot be represented in type 'long'
Fixes: 26471/clusterfuzz-testcase-minimized-ffmpeg_dem_MXG_fuzzer-6229617557635072

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

Comments

Michael Niedermayer Oct. 25, 2020, 9 a.m. UTC | #1
On Tue, Oct 20, 2020 at 10:56:19PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 9223372036854770375 + 5450 cannot be represented in type 'long'
> Fixes: 26471/clusterfuzz-testcase-minimized-ffmpeg_dem_MXG_fuzzer-6229617557635072
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavutil/mathematics.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]
diff mbox series

Patch

diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c
index 16c6e4db03..da0fc17b2e 100644
--- a/libavutil/mathematics.c
+++ b/libavutil/mathematics.c
@@ -210,6 +210,6 @@  int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t i
         if (old == INT64_MAX || old == AV_NOPTS_VALUE || old_ts == AV_NOPTS_VALUE)
             return ts;
 
-        return av_rescale_q(old + 1, inc_tb, ts_tb) + (ts - old_ts);
+        return av_sat_add64(av_rescale_q(old + 1, inc_tb, ts_tb), ts - old_ts);
     }
 }