ffmpeg | branch: master | Michael Niedermayer <mich...@niedermayer.cc> | Tue 
Jun 17 01:05:54 2025 +0200| [c909ef31be96b6983698c3b01c675de8e5f2637a] | 
committer: Michael Niedermayer

avcodec/osq: Fix signed integer overflow in update_stats()

Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an 
unsigned type to negate this value to itself
Fixes: 
410109093/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6550900028276736

Note, none of the available osq files uses update_stats(), this change may fix 
or break
files using coding_mode == 2. The code prior looks wrong though

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

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

 libavcodec/osq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/osq.c b/libavcodec/osq.c
index 1e94a486e9..14c723ed9c 100644
--- a/libavcodec/osq.c
+++ b/libavcodec/osq.c
@@ -146,8 +146,8 @@ static void reset_stats(OSQChannel *cb)
 
 static void update_stats(OSQChannel *cb, int val)
 {
-    cb->sum += FFABS(val) - cb->history[cb->pos];
-    cb->history[cb->pos] = FFABS(val);
+    cb->sum += FFABS((int64_t)val) - cb->history[cb->pos];
+    cb->history[cb->pos] = FFABS((int64_t)val);
     cb->pos++;
     cb->count++;
     if (cb->pos >= FF_ARRAY_ELEMS(cb->history))

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to