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

Simon 'corecode' Schubert corecode at fs.ei.tum.de
Thu Jul 7 01:25:42 PDT 2005


Lately Matthew Dillon <dillon at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00015.pgp
Type: application/octet-stream
Size: 189 bytes
Desc: "Description: PGP signature"
URL: <http://lists.dragonflybsd.org/pipermail/commits/attachments/20050707/a837fc33/attachment-0020.obj>


More information about the Commits mailing list