|
Message-ID: <20241030030724.733422-1-lihua.zhao.cn@windriver.com> Date: Wed, 30 Oct 2024 11:07:24 +0800 From: <lihua.zhao.cn@...driver.com> To: <musl@...ts.openwall.com> CC: <lihua.zhao.cn@...driver.com> Subject: [PATCH v2] signal: set EINVAL for sigismember when sig is invalid From: Lihua Zhao <lihua.zhao.cn@...driver.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
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.