git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Usage of isspace and friends
@ 2005-10-12  1:40 Morten Welinder
  2005-10-13  6:49 ` Junio C Hamano
  0 siblings, 1 reply; 10+ messages in thread
From: Morten Welinder @ 2005-10-12  1:40 UTC (permalink / raw)
  To: GIT Mailing List

Someone needs to audit the usage of isspace, tolower, and friends.  There are
things like this in the code:

static int is_dev_null(const char *str)
{
	return !memcmp("/dev/null", str, 9) && isspace(str[9]);
}

Since str[9] is of type char it should not be used as a argument to
isspace directly,
but rather be cast to unsigned char:

    ... isspace((unsigned char)str[9]);

Admittedly that is ugly.  Blame K&R.  (Glibc has a partial workaround for this
kind of coding bug.  On the up side you won't get a crash, but on the down
side you can get the wrong result.)

Morten

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-10-13 16:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-12  1:40 Usage of isspace and friends Morten Welinder
2005-10-13  6:49 ` Junio C Hamano
2005-10-13  8:29   ` Antti-Juhani Kaijanaho
2005-10-13 13:27   ` H. Peter Anvin
2005-10-13 15:44     ` Junio C Hamano
2005-10-13 15:04   ` Linus Torvalds
2005-10-13 15:45     ` H. Peter Anvin
2005-10-13 15:56       ` Linus Torvalds
2005-10-13 16:07         ` H. Peter Anvin
2005-10-13 15:46     ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).