From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id 94E9030AA9 for ; Tue, 29 Oct 2024 14:13:05 +0100 (CET) Received: (qmail 8088 invoked by uid 550); 29 Oct 2024 13:13:01 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com x-ms-reactions: disallow Received: (qmail 8055 invoked from network); 29 Oct 2024 13:13:01 -0000 Date: Tue, 29 Oct 2024 14:12:49 +0100 (CET) From: Thorsten Glaser To: musl@lists.openwall.com cc: lihua.zhao.cn@windriver.com In-Reply-To: <20241029130234.729799-1-lihua.zhao.cn@windriver.com> Message-ID: <63e3ced1-1b7d-8427-0105-a865d21f7e6f@evolvis.org> References: <20241029130234.729799-1-lihua.zhao.cn@windriver.com> Content-Language: de-Zsym-DE-1901-u-em-text-rg-denw-tz-utc, en-Zsym-GB-u-cu-eur-em-text-fw-mon-hc-h23-ms-metric-mu-celsius-rg-denw-tz-utc-va-posix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Subject: Re: [musl] [PATCH] set EINVAL for sigismember when sig is invalid On Tue, 29 Oct 2024, lihua.zhao.cn@windriver.com wrote: > int sigismember(const sigset_t *set, int sig) > { > =09unsigned s =3D sig-1; >-=09if (s >=3D _NSIG-1) return 0; >+=09if (s < 0 || s >=3D _NSIG-1) { unsigned s can never be 0, and assignment from int will wrap around, so the >=3D is enough. There=E2=80=99s UB if sig =3D=3D INT_MIN though. - =09unsigned s =3D sig-1; + =09unsigned s =3D sig; + =09++s; Or: - =09unsigned s =3D sig-1; + =09unsigned s =3D (unsigned)sig - 1U; bye, //mirabilos --=20 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.=09-- Ragge No faith left in ISO C99, undefined behaviour, etc.