From: <lihua.zhao.cn@windriver.com>
To: <musl@lists.openwall.com>
Cc: <lihua.zhao.cn@windriver.com>
Subject: [musl] [PATCH v2] signal: set EINVAL for sigismember when sig is invalid
Date: Wed, 30 Oct 2024 11:07:24 +0800 [thread overview]
Message-ID: <20241030030724.733422-1-lihua.zhao.cn@windriver.com> (raw)
In-Reply-To: <20241029130234.729799-1-lihua.zhao.cn@windriver.com>
From: Lihua Zhao <lihua.zhao.cn@windriver.com>
sigismember() forget to set errno when input sig is invalid
---
src/signal/sigismember.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/signal/sigismember.c b/src/signal/sigismember.c
index ab87d622..3ecd300f 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;
+ unsigned s = sig-1U;
+ if (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
prev parent reply other threads:[~2024-10-30 3:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-29 13:02 [musl] [PATCH] " lihua.zhao.cn
2024-10-29 13:12 ` Thorsten Glaser
2024-10-29 20:26 ` Rich Felker
2024-10-30 3:07 ` lihua.zhao.cn [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241030030724.733422-1-lihua.zhao.cn@windriver.com \
--to=lihua.zhao.cn@windriver.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).