DragonFly BSD
DragonFly commits List (threaded) for 2005-07
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: cvs commit: src/include ctype.h src/lib/libc/gen isctype.c tolower.c toupper.c


From: "Simon 'corecode' Schubert" <corecode@xxxxxxxxxxxx>
Date: Thu, 7 Jul 2005 10:24:51 +0200

Lately Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxxxxx> said:
>   Log:
>   It is not acceptable to index the array out of bounds if an illegal index
>   is passed to a ctype function or macro.  Undo the last commit.  Emplace an
>   explicit range check for the integer passed to the ctype macros and
>   functions rather then underflowing or overflowing the array.  Currently
>   return 0 if the integer is out of range (it might be more appropriate to
>   assert).

hm. this doesn't really add value to your testing case for passing signed
chars. now they all appear non-printable - and not like the integer
equivalent, as the naive programmer would expect. I would prefer the
openbsd way:
	if (c == EOF)
		return 0;
	else
		return ((table+1)[(unsigned char)c)]);

this gives expected results for (common?) misuse and even saves us one
conditional.

cheers
  simon

-- 
Serve - BSD     +++  RENT this banner advert  +++    ASCII Ribbon   /"\
Work - Mac      +++  space for low $$$ NOW!1  +++      Campaign     \ /
Party Enjoy Relax   |   http://dragonflybsd.org      Against  HTML   \
Dude 2c 2 the max   !   http://golden-apple.biz       Mail + News   / \

Attachment: pgp00015.pgp
Description: PGP signature



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]