Bugtraq mailing list archives

Re: ftpd: the advisory version


From: bernd.luevelsmeyer () HEITEC NET (Bernd Luevelsmeyer)
Date: Sun, 25 Jun 2000 09:43:19 +0200


Lamagra Argamal wrote:
[...]
There are some other bugs in site_exec like
    for (t = cmd; *t && !isspace(*t); t++) {
        if (isupper(*t)) {
            *t = tolower(*t);
        }
    }

Sanitizing stops at a space?? (good thing I didn't tell you this, eh tf8)
[...]

According to the C standard, <ctype.h> functions operate on values that
are representable as a 'unsigned char' or EOF; hence, if the compiler's
'char' is signed then negative character values in the string 'cmd' are
possible and might cause unpredictable results in isspace(), isupper()
and tolower(). Because sanitizing shouldn't stop, and the test with
isupper() is unnecessary anyway (tolower() returns the unchanged value
if the parameter isn't an uppercase letter), I suggest:
     for (t = cmd; *t; t++)
             *t = tolower((unsigned char)*t);


Current thread: