summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHauke Mehrtens2026-04-08 22:24:13 +0000
committerHauke Mehrtens2026-06-18 22:06:44 +0000
commitad15219cb1fa0fb90b37bcef50fe3f4e0e1966a9 (patch)
tree49293560762a8075df042df462fef526125465a7
parente1dc23a2518c8f6e3ba0f795a9791d9c6f97c21b (diff)
downloadlibubox-ad15219cb1fa0fb90b37bcef50fe3f4e0e1966a9.tar.gz
uloop: fix undefined behavior in signal bit operations for signals > 32
set_signo() and get_signo() use 1u (unsigned int, 32-bit) as the base for left-shifting by (signo - 1). For real-time signals with signal numbers 33-64, this shift exceeds the width of unsigned int, which is undefined behavior per the C standard. Use UINT64_C(1) to match the uint64_t type of the signums variable and correctly handle all 64 possible signals. Link: https://github.com/openwrt/libubox/pull/42 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> (cherry picked from commit 03821f942c499841c8c9fd52ebf7f4d4a97f752b)
-rw-r--r--uloop.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/uloop.c b/uloop.c
index b3a7ff6..d7126ad 100644
--- a/uloop.c
+++ b/uloop.c
@@ -85,12 +85,12 @@ int uloop_fd_add(struct uloop_fd *sock, unsigned int flags);
static void set_signo(uint64_t *signums, int signo)
{
if (signo >= 1 && signo <= 64)
- *signums |= (1u << (signo - 1));
+ *signums |= (UINT64_C(1) << (signo - 1));
}
static bool get_signo(uint64_t signums, int signo)
{
- return (signo >= 1) && (signo <= 64) && (signums & (1u << (signo - 1)));
+ return (signo >= 1) && (signo <= 64) && (signums & (UINT64_C(1) << (signo - 1)));
}
static void signal_consume(struct uloop_fd *fd, unsigned int events)