[FFmpeg-cvslog] avutil/mathematics: Fix undefined negation in av_compare_ts()

Michael Niedermayer git at videolan.org
Wed Feb 10 13:42:56 EET 2021


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sun Jan 31 15:51:40 2021 +0100| [7a239526146934a50c1cebd25e079a1027db545c] | committer: Michael Niedermayer

avutil/mathematics: Fix undefined negation in av_compare_ts()

Fixes: negation of -9223372036854775808 cannot be represented in type 'int64_t' (aka 'long'); cast to an unsigned type to negate this value to itself
Fixes: 29437/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-4748510022991872

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

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

diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c
index da0fc17b2e..2de2b39da0 100644
--- a/libavutil/mathematics.c
+++ b/libavutil/mathematics.c
@@ -148,7 +148,7 @@ int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
 {
     int64_t a = tb_a.num * (int64_t)tb_b.den;
     int64_t b = tb_b.num * (int64_t)tb_a.den;
-    if ((FFABS(ts_a)|a|FFABS(ts_b)|b) <= INT_MAX)
+    if ((FFABS64U(ts_a)|a|FFABS64U(ts_b)|b) <= INT_MAX)
         return (ts_a*a > ts_b*b) - (ts_a*a < ts_b*b);
     if (av_rescale_rnd(ts_a, a, b, AV_ROUND_DOWN) < ts_b)
         return -1;



More information about the ffmpeg-cvslog mailing list