[FFmpeg-cvslog] swscale/swscale: Use unsigned operation to avoid undefined behavior

Michael Niedermayer git at videolan.org
Sun Jan 5 01:29:42 EET 2025


ffmpeg | branch: release/2.8 | Michael Niedermayer <michael at niedermayer.cc> | Thu Sep 12 20:08:42 2024 +0200| [3cdb0aa5a0533064b08d48de37759c431145771b] | committer: Michael Niedermayer

swscale/swscale: Use unsigned operation to avoid undefined behavior

I have not checked that the constant is correct, this just fixes the undefined behavior

Fixes: signed integer overflow: -646656 * 3517 cannot be represented in type 'int
Fixes: 70559/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-5209368631508992

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 44c5641ae82387fcfce94820f5b53ce8e9dcd27f)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libswscale/swscale.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index e1b5bb8241..9c6f25df97 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -235,7 +235,7 @@ static void lumRangeFromJpeg16_c(int16_t *_dst, int width)
     int i;
     int32_t *dst = (int32_t *) _dst;
     for (i = 0; i < width; i++)
-        dst[i] = (dst[i]*(14071/4) + (33561947<<4)/4)>>12;
+        dst[i] = ((int)(dst[i]*(14071U/4) + (33561947<<4)/4)) >> 12;
 }
 
 // *** horizontal scale Y line to temp buffer



More information about the ffmpeg-cvslog mailing list