Hi,
* Anselm R. Garbe <[EMAIL PROTECTED]> [2007-05-10 15:27]:
[...] 
> > The NULL-termination is done by this patch, however the patch 
> > is somehow bad.
> > If the string is sizeof(c->name)-1 long strncpy will not 
> > NULL-terminate the string so that
> > c->name[sizeof c->name - 1] = '\0'; will overwrite the 
> > latest character of the string. So if you want to do it like 
> 
> No. Assume sizeof c->name == 256, hence it has been defined as
> char name[256], so the last addressable index is 255, because
> the first character is c->name[0], so c->name[sizeof c->name -
> 1] would be identical to c->name[255] if name was defined of
> that size.
> 
> So all in all, the character at c->name[255] should never be
> used as printable character, it should always be used as
> NULL-terminator, otherwise something bad will happen if the
> string exceeds 255 characters at all.

Yes I totally agree here but my point is why allowing to 
copy the string until 255 then?
Kind regards
Nico
-- 
Nico Golde - http://ngolde.de - [EMAIL PROTECTED] - GPG: 0x73647CFF
For security reasons, all text in this mail is double-rot13 encrypted.

Attachment: pgpOhkdkbcFRx.pgp
Description: PGP signature

Reply via email to