Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241029130234.729799-1-lihua.zhao.cn@windriver.com>
Date: Tue, 29 Oct 2024 21:02:34 +0800
From: <lihua.zhao.cn@...driver.com>
To: <musl@...ts.openwall.com>
CC: <lihua.zhao.cn@...driver.com>
Subject: [PATCH] set EINVAL for sigismember when sig is invalid

From: Lihua Zhao <lihua.zhao.cn@...driver.com>

---
 src/signal/sigismember.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/signal/sigismember.c b/src/signal/sigismember.c
index ab87d622..0b33888c 100644
--- a/src/signal/sigismember.c
+++ b/src/signal/sigismember.c
@@ -1,8 +1,12 @@
 #include <signal.h>
+#include <errno.h>
 
 int sigismember(const sigset_t *set, int sig)
 {
 	unsigned s = sig-1;
-	if (s >= _NSIG-1) return 0;
+	if (s < 0 || s >= _NSIG-1) {
+		errno = EINVAL;
+		return -1;
+	}
 	return !!(set->__bits[s/8/sizeof *set->__bits] & 1UL<<(s&8*sizeof *set->__bits-1));
 }
-- 
2.34.1

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.