X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA2DD3858421
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1704239788;
	bh=Abb7Q8ZFwxirm0KSJctrRpQyDk+v/igsK3mmtbvSfB4=;
	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=Tf6yIG9eZryOJCaFKmXurNq5FmAfzdBDLRsNIKbD92L9ybnNkQfepcaY3k7tw2uAL
	 RW/z5PT9b603++LDGdSwrDhLHxRttYGkuhk5QD9djzPz5KEI8/tcYOBmC3IAh79Gs1
	 0QVkg4235wCDyTKK6ss1oSvYi9c+hzh2/ZqyDXbI=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 16E423858C66
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 16E423858C66
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704239765; cv=none;
 b=JT55n+LrBMG0BvklDrjcRlGQVu1EbKqJS4I7hfcJpNsOU4++IGD28mIw8EcEZkcpeAp2sTpfsoViVGE5V7sM7mYc8iXDsyJap8eVA/2lU6MO9CZavFY2SIDhNAoiRib2zpr2WkCj5NjE22+HNawA2GXm31KimujXFLLx2cTYB1U=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1704239765; c=relaxed/simple;
 bh=dm7gXK/s6ZZkERPw17rs7/rgHJnli16+1+7LmGBA3dg=;
 h=DKIM-Signature:MIME-Version:Date:From:To:Subject:Message-ID;
 b=LPYJf5dGL0Dogb+70TbkNlC4DddI18WboBiY7YVEJ8aTMU8SuneeYUC7RXLF0aEQ6WWI8BSjNKYQRAqjz/bW/AqnYFXc4hdJJNz2M6Ew5OnHnixUVce2E4caRdtE8BbcQeVyJvor/z4A9g49JsAZgP64gA0I0BRpLH59Qy5ERrQ=
ARC-Authentication-Results: i=1; server2.sourceware.org
X-Authority-Analysis: v=2.4 cv=KJNJsXJo c=1 sm=1 tr=0 ts=6594a293
 a=pMSlDXUwMa7SJ1EIez8PdQ==:117 a=pMSlDXUwMa7SJ1EIez8PdQ==:17
 a=xqWC_Br6kY4A:10 a=kj9zAlcOel0A:10 a=dEuoMetlWLkA:10 a=w_pzkKWiAAAA:8
 a=FmBjbIXLQAWKDt60SAYA:9 a=CjuIK1q_8ugA:10 a=zZCYzV9kfG8A:10
 a=sRI3_1zDfAgwuvI8zelB:22
MIME-Version: 1.0
Date: Tue, 02 Jan 2024 15:56:00 -0800
To: Takashi Yano <takashi.yano@nifty.ne.jp>
Cc: cygwin@cygwin.com
Subject: Re: Possibly buggy use of ctype.h macros.
In-Reply-To: <20240103082556.8ba92d98e1023f6e6fb175e2@nifty.ne.jp>
References: <e7301d2e6aef776277cd6d81be0424a8@kylheku.com>
 <20240103082556.8ba92d98e1023f6e6fb175e2@nifty.ne.jp>
User-Agent: Roundcube Webmail/1.4.15
Message-ID: <5d6e0d9bbeef1d4184b6067845d1e5a5@kylheku.com>
X-Sender: kaz@kylheku.com
X-CMAE-Envelope: MS4xfFWpoA9F6WG6ym/TTpaWMwDqrxwQKZesNC9NQGUFa+XlyEsC1eunUhJQdTdE5N3+GM47CCs9VYm11yo/DpTSaIcuK871/DesxUpmyQK/eH38czZ8C+0+
 o4RNkEN1FDWtOweZGLCWIF4GY5jgt+JWRws8qcnT/rXJo+MOEtfPx2vK4AZKUiT1064t2psTmQX+Vi4BKxKoj+e8cfsWRjIvu7o=
X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, DKIM_SIGNED,
 DKIM_VALID, DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_LOW,
 SPF_HELO_NONE, 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@cygwin.com
X-Mailman-Version: 2.1.30
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Kaz Kylheku via Cygwin <cygwin@cygwin.com>
Reply-To: Kaz Kylheku <kaz@kylheku.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cygwin-bounces+archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>

On 2024-01-02 15:25, Takashi Yano via Cygwin wrote:
> On Tue, 02 Jan 2024 14:18:15 -0800
> Kaz Kylheku via Cygwin <cygwin@cygwin.com> 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.)


-- 
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
