X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2DDA53858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1704240752; bh=DnZRoEKXSK8TT25BTTLeroLi5IxOB9W30KhUYjl4wXc=; h=Date:To:Cc:Subject:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Vzk27Ft8QZZUcPnXuLOv2iKiscsMNFWymX+Qp9nxhCCUwYZx32FxgNxwO88Bqw+LB tOwnijSLTdwB5dXBxPJNg5UaM+CCYyezajvJ8cpac31xjlqVygr5kusHduS2uAeitE 31nB8ivhEK5kd0Z0onU+XtTOmf0V/tBRy2xqItD4= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B3C483858C66 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B3C483858C66 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704240689; cv=none; b=UMEUpgyym5ykQ9WT3c83wIb2O7vP5ye2MY5Vw9o3IkHan+D2utCs4BwkcERmUoC0XtM1wNuv+vemoLWqZ+M3ZhY0r8qZWDMDIjuPA6vFajFS+pgn3Dz8pqXlBfBl69X8Mkf8/q/6GiR47q6pamSEoJuodLbPLe+0eTPo0OqlnL0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704240689; c=relaxed/simple; bh=pGXcOqR0CGzQQG2W3oFg9c92S7eklo0ee7RarvdCC10=; h=Date:From:To:Subject:Message-Id:Mime-Version; b=xYlfxVM+vw0O+thlrqWka8/oLoZowYIZPyXcJPHT+HWS1hFR+KI6nfEK967feAk+4W4SYAxWQLanT5FYBpTh/NI1ExhnLP+r8CvnFBpODPhoighe7WbjfBQywFT9+aXqTNI3qBesi8znjy7QGWF9prTCYGM83oZWsEHK07enr2Y= ARC-Authentication-Results: i=1; server2.sourceware.org Date: Wed, 3 Jan 2024 09:11:24 +0900 To: cygwin AT cygwin DOT com Cc: Kaz Kylheku Subject: Re: Possibly buggy use of ctype.h macros. Message-Id: <20240103091124.7b4b9e2f7a896c0c2fe416ab@nifty.ne.jp> In-Reply-To: <5d6e0d9bbeef1d4184b6067845d1e5a5@kylheku.com> References: <20240103082556 DOT 8ba92d98e1023f6e6fb175e2 AT nifty DOT ne DOT jp> <5d6e0d9bbeef1d4184b6067845d1e5a5 AT kylheku DOT com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Takashi Yano via Cygwin Reply-To: Takashi Yano Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" On Tue, 02 Jan 2024 15:56:00 -0800 Kaz Kylheku wrote: > On 2024-01-02 15:25, Takashi Yano via Cygwin wrote: > > On Tue, 02 Jan 2024 14:18:15 -0800 > > Kaz Kylheku via Cygwin wrote: > >> I noticed that this macro, defined in winsup/cygwin/local_includes/path.h: > >> > >> #define isdrive(s) (isalpha (*(s)) && (s)[1] == ':') > >> > >> is being used with arguments of type char, like dereferenced "char *" pointers. > >> > >> Unless the isalpha implementation is robust against this, it should be isalpha((unsigned char) *(s)). > > > > > > https://cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=newlib/libc/ctype/ctype_.h;h=a73870b3e4ade5545fd41bcc6f10446a22b4b46e;hb=HEAD > > I see, so on Cygwin, the negative index is allowed, thanks to a displacement. > > # define DEFAULT_CTYPE_PTR ((char *) _ctype_b + 127) > > But, 127? A (signed) char can go to -128. '\x80' will access _ctype_b[-1]. Is that also somehow OK? > > (Tangential remark: all ctype implementations have to handle at least one negative value, namely EOF.) https://cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=newlib/libc/ctype/isalpha.c;h=8b8e78a296359a4a8b3687fd76b1b73cd707a6da;hb=HEAD Perhaps, the off-by-one is for EOF as you guess. -- Takashi Yano -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple