From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dmta0006.nifty.com (mta-snd00006.nifty.com [106.153.226.38]) by sourceware.org (Postfix) with ESMTPS id B3C483858C66 for ; Wed, 3 Jan 2024 00:11:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B3C483858C66 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=nifty.ne.jp Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nifty.ne.jp ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B3C483858C66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=106.153.226.38 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 Received: from HP-Z230 by dmta0006.nifty.com with ESMTP id <20240103001124577.YCSG.24077.HP-Z230@nifty.com>; Wed, 3 Jan 2024 09:11:24 +0900 Date: Wed, 3 Jan 2024 09:11:24 +0900 From: Takashi Yano To: cygwin@cygwin.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.8ba92d98e1023f6e6fb175e2@nifty.ne.jp> <5d6e0d9bbeef1d4184b6067845d1e5a5@kylheku.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 List-Id: 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