Source-Changes-D archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: CVS commit: src/crypto/dist/openssl/apps
Date: Wed, 15 Apr 2009 00:08:30 +0100
From: David Laight <david%l8s.co.uk@localhost>
Message-ID: <20090414230830.GC4191%snowdrop.l8s.co.uk@localhost>
| The ctype functions are often implemented as #defines that index arrays,
| so if the argument is 'char' it is very likely to index off the front
| which leads to an unexpected result or core dump.
Yes, the "undefined behaviour" from the man page...
| I suspect the gcc warning here is present precisely to detect bad use
| of the ctype functiuons.
Very likely true, but it is still dumb, as in C "char" is just an int
type, outlawing indexing by char is no more sane than outlawing indexing
by short or int.
At one stage, BSD (real B BSD) unnecessarily "fixed" this by simply
allocating space in the _ctyle[] arrays with negative offsets - there's
also nothing wrong with using a negative array offset in C, provided that
the pointer it is being offset from points beyond the start of the
allocated space.
| Actually islower() used to be a requirement, old SYSV systems used the
| same array for toupper() and tolower().
Yes - and as I recall (which no-one should place much reliance upon the
accuracy of), the earliest implementations were ((c)^0x20) which
would simply have been meaningless (and wildly incorrect) if the char
didn't have the assumed case to begin with (or wasn't ascii).
kre
Home |
Main Index |
Thread Index |
Old Index