Blame xscreensaver-6.07-0001-make_ximage-avoid-integer-overflow-on-left-shift.patch
|
|
2588b3a |
From 27aa984fdcaf8d44d6260ea2da7a0f5cc78a8b13 Mon Sep 17 00:00:00 2001
|
|
|
2588b3a |
From: XScreenSaver owners <xscreensaver-owner@fedoraproject.org>
|
|
|
2588b3a |
Date: Fri, 1 Sep 2023 16:14:50 +0900
|
|
|
2588b3a |
Subject: [PATCH] make_ximage: avoid integer overflow on left shift
|
|
|
2588b3a |
|
|
|
2588b3a |
gcc -fsanitize=undefined shows the following undefined behavior:
|
|
|
2588b3a |
../../hacks/ximage-loader.c:176:29: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'
|
|
|
2588b3a |
This is because of integral promotion from guchar to int, not to unsigned int.
|
|
|
2588b3a |
|
|
|
2588b3a |
To avoid this error, cast to unsigned type.
|
|
|
2588b3a |
---
|
|
|
2588b3a |
hacks/ximage-loader.c | 2 +-
|
|
|
2588b3a |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
2588b3a |
|
|
|
2588b3a |
diff --git a/hacks/ximage-loader.c b/hacks/ximage-loader.c
|
|
|
2588b3a |
index 9bd7970..a3f6eb0 100644
|
|
|
2588b3a |
--- a/hacks/ximage-loader.c
|
|
|
2588b3a |
+++ b/hacks/ximage-loader.c
|
|
|
2588b3a |
@@ -173,7 +173,7 @@ make_ximage (Display *dpy, Visual *visual, const char *filename,
|
|
|
2588b3a |
i += 3;
|
|
|
2588b3a |
break;
|
|
|
2588b3a |
case 4:
|
|
|
2588b3a |
- rgba = ((i[3] << 24) |
|
|
|
2588b3a |
+ rgba = ((((unsigned long)i[3]) << 24) |
|
|
|
2588b3a |
(i[2] << 16) |
|
|
|
2588b3a |
(i[1] << 8) |
|
|
|
2588b3a |
i[0]);
|
|
|
2588b3a |
--
|
|
|
2588b3a |
2.41.0
|
|
|
2588b3a |
|