Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Aug 2005 00:38:00 +1000
From:      Tim Robbins <tjr@freebsd.org>
To:        Andrey Chernov <ache@FreeBSD.ORG>
Cc:        cvs-src@FreeBSD.ORG, src-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG
Subject:   Re: cvs commit: src/lib/libc/regex regex2.h
Message-ID:  <42FE05C8.1080600@freebsd.org>
In-Reply-To: <20050813120150.GA33192@nagual.pp.ru>
References:  <200508130230.j7D2UGSp002570@repoman.freebsd.org> <20050813120150.GA33192@nagual.pp.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
Andrey Chernov wrote:

>On Sat, Aug 13, 2005 at 02:30:16AM +0000, Tim J. Robbins wrote:
>  
>
>>tjr         2005-08-13 02:30:16 UTC
>>
>>  FreeBSD src repository
>>
>>  Modified files:
>>    lib/libc/regex       regex2.h 
>>  Log:
>>  Change OUT from -2 to CHAR_MIN-1, making it impossible for it to
>>  inadvertently match a negative char in the RE being compiled.
>>    
>>
>
>It seems this commit may mask the bug where signed comparison used.
>Better fix perhaps to make compared char unsigned in all places, i.e.
>	if (-2 == (unsigned char)'\254')
>
>  
>
For whatever reason, the "stop" argument to p_ere() and the "stop1" and 
"stop2" arguments to p_bre() are signed chars cast to int, not unsigned 
chars cast to int, so OUT needs to be outside the valid range of char, 
not unsigned char. This is somewhat unconventional, but I don't think 
the new value of CHAR_MIN-1 is any worse than the pre- rev. 1.8 value of 
CHAR_MAX+1. The choice of -2 in rev. 1.8 was a mistake on my part caused 
by not realising that characters were being passed around as signed 
chars cast to int.

Tim



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?42FE05C8.1080600>