Non-standard conformant usage of ctype functions

Corinna Vinschen vinschen at redhat.com
Wed Jul 8 18:24:34 EST 2009


On Jul  7 22:46, Roumen Petrov wrote:
> Corinna Vinschen wrote:
>> For obvious reasons this results in problems if you use signed char
>> variables as parameters in calls to the ctype functions, if you support
>> other charsets than ASCII.
>> In theory OpenSSH has this problem as well.  With a few exceptions it
>> uses (signed) char values throughout in calls to ctype functions like
>> isspace.
>
> No idea why is not reported.

It's reported when using the latest Cygwin.  The underlying C library,
newlib, recently changed the ctype.h macros so that a -Wall warning
"array subscript has type 'char'" gets triggered.

>> However, given that OpenSSH doesn't call setlocale, the locale is always
>> "C" and the chance that the ctype functions return a wrong value is rather
>> tiny.  Nevertheless, for the sake of correctness, and to avoid potential
>> problems in some later, locale-aware version of OpenSSH, I'd like to
>> propose to change all calls of ctype functions in OpenSSH from, for
>> instance:
>> [...]
> I think that other functions like isalpha, isdigit are impacted too.

All isFOO functions are affected, as well as toupper/tolower.

>> If that's ok with you, I'd create a matching patch.
> May be a patch based on macros like ISPACE above, but the question is  
> why to patch code if it not reported a issue ?

That's what I was trying to explain above.  However, if the OpenSSH
maintainers think this is not worth a fix, I let it go.


Corinna

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


More information about the openssh-unix-dev mailing list