mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] set EINVAL for sigismember when sig is invalid
@ 2024-10-29 13:02 lihua.zhao.cn
  2024-10-29 13:12 ` Thorsten Glaser
  2024-10-30  3:07 ` [musl] [PATCH v2] signal: " lihua.zhao.cn
  0 siblings, 2 replies; 4+ messages in thread
From: lihua.zhao.cn @ 2024-10-29 13:02 UTC (permalink / raw)
  To: musl; +Cc: lihua.zhao.cn

From: Lihua Zhao <lihua.zhao.cn@windriver.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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-30  3:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-29 13:02 [musl] [PATCH] set EINVAL for sigismember when sig is invalid lihua.zhao.cn
2024-10-29 13:12 ` Thorsten Glaser
2024-10-29 20:26   ` Rich Felker
2024-10-30  3:07 ` [musl] [PATCH v2] signal: " lihua.zhao.cn

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).