Vulnerability Development mailing list archives

Re: C versus other languages, round 538 or so (Re: CGI scriptsinsh)


From: Peter Pentchev <roam () ORBITEL BG>
Date: Mon, 2 Oct 2000 17:49:40 +0300

On Mon, Oct 02, 2000 at 02:03:25AM +0200, Bluefish (P.Magnusson) wrote:
Looking at James' comments in the fixup;
// (sizeof(variable)-1) instead of sizeof(variable) - NULL, \0, 0

It's beyond me what he's actually wants to spell out.
  sizeof(variable) - NULL         == sizeof(variable) - 0
  sizeof(variable) - sizeof(NULL) == sizeof(variable) - 4 (if NULL 32bit)

I think he meant "Using (sizeof(variable)-1) instead of sizeof(variable)
because we have to account for the last character/byte being NULL (or \0,
or 0, or whatever you want to call it)"... or something like that :)

G'luck,
Peter

--
If I had finished this sentence,


Current thread: