diff mbox series

[FFmpeg-devel,03/12] avutil/mathematics: Fix undefined negation in av_compare_ts()

Message ID 20210131191818.17203-3-michael@niedermayer.cc
State Accepted
Commit 7a239526146934a50c1cebd25e079a1027db545c
Headers show
Series [FFmpeg-devel,01/12] avcodec/hevc_sei: Check payload size in decode_nal_sei_message() | expand


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. 31, 2021, 7:18 p.m. UTC
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@niedermayer.cc>
 libavutil/mathematics.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series


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;