Subject: Re: lib/34632: isalpha() and possibly other ctype functions segfault
To: None <lib-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: David Laight <david@l8s.co.uk>
List: netbsd-bugs
Date: 09/26/2006 23:55:03
The following reply was made to PR lib/34632; it has been noted by GNATS.

From: David Laight <david@l8s.co.uk>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: lib/34632: isalpha() and possibly other ctype functions segfault
Date: Wed, 27 Sep 2006 00:49:53 +0100

 On Tue, Sep 26, 2006 at 07:37:36PM -0400, Christos Zoulas wrote:
 > | Other systems (AIX, MacOS, various Linuxes) have chosen a user-friendly way and return 0.
 
 Are you sure ?
 The isxxx() 'functions' are almost always implemented (and were designed to
 be implemented) as an array lookup checking for several bits.
 Since the domain of the functions is 'all the values of unsigned char + EOF'
 it is typically -1..255, calling the function with an -ve value in a
 signed char indexes off the front of the array.  If you are lucky this
 doesn't have the relevent bit(s) set and is a zero, it might have a
 bit set and return 1, it might not be mapped and so core dump.
 The standards allow 'undefined' behaviour - this includes formatting
 your hard disk or crushing your nuts.
 
 	David
 
 -- 
 David Laight: david@l8s.co.uk