|
Message-ID: <63e3ced1-1b7d-8427-0105-a865d21f7e6f@evolvis.org> Date: Tue, 29 Oct 2024 14:12:49 +0100 (CET) From: Thorsten Glaser <tg@...lvis.org> To: musl@...ts.openwall.com cc: lihua.zhao.cn@...driver.com Subject: Re: [PATCH] set EINVAL for sigismember when sig is invalid On Tue, 29 Oct 2024, lihua.zhao.cn@...driver.com wrote: > int sigismember(const sigset_t *set, int sig) > { > unsigned s = sig-1; >- if (s >= _NSIG-1) return 0; >+ if (s < 0 || s >= _NSIG-1) { unsigned s can never be 0, and assignment from int will wrap around, so the >= is enough. There’s UB if sig == INT_MIN though. - unsigned s = sig-1; + unsigned s = sig; + ++s; Or: - unsigned s = sig-1; + unsigned s = (unsigned)sig - 1U; bye, //mirabilos -- In traditional syntax ' is ignored, but in c99 everything between two ' is handled as character constant. Therefore you cannot use ' in a preproces- sing file in c99 mode. -- Ragge No faith left in ISO C99, undefined behaviour, etc.
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.