Vulnerability Development mailing list archives
Re: Secure coding in C (was Re: Administrivia #4883)
From: bet () RAHUL NET (Bennett Todd)
Date: Fri, 14 Jan 2000 16:58:33 -0500
2000-01-14-16:48:50 Marco Walther:
BT> snprintf(c, len, "%s%s", a, b) > 0 || die "snprintf"; You're dead! Use (*a == '\0' && *b == '\0') and snprintf() returns `0'!!
Thanks for the tip. I knew about, and ignored that possibility; in this case the values I'm concatenating come from various sources, some of which are guaranteed to be non-null, and the format string actually includes some literal characters, not just a bunch of %s's. I'm building up a maildir file name, actually. And I _know_ that someone, someday, is going to use my program to pick a field out of the header and directly use that as a folder name, so I better be able to soak up hostile strings showing up:-). And for whatever it's worth, I consider ``die("snprintf")'' to be a healthy response to an otherwise-unchecked hostile string, at least in this setting:-). -Bennett <HR NOSHADE> <UL> <LI>application/pgp-signature attachment: stored </UL>
Current thread:
- Administrivia #4883 Blue Boar (Jan 13)
- Re: Administrivia #4883 Marc (Jan 13)
- Re: Administrivia #4883 Travis Siegel (Jan 13)
- [Fwd: Administrivia #4883] Blue Boar (Jan 13)
- Firewall-1 Logging *Issue* Mike Frantzen (Jan 13)
- Re: Firewall-1 Logging *Issue* Blue Boar (Jan 13)
- Re: Administrivia #4883 nascheme () ENME UCALGARY CA (Jan 14)
- Secure coding in C (was Re: Administrivia #4883) Bennett Todd (Jan 14)
- Re: Secure coding in C (was Re: Administrivia #4883) Marco Walther (Jan 14)
- Re: Secure coding in C (was Re: Administrivia #4883) Bennett Todd (Jan 14)
- Re: Secure coding in C (was Re: Administrivia #4883) Liviu Daia (Jan 14)
- Re: Secure coding in C (was Re: Administrivia #4883) spin0ff (Jan 16)
- ICQ >= 99* + CC Data (Was: Re: Administrivia #4883) Ken Williams (Jan 16)
- Re: ICQ >= 99* + CC Data Vanja Hrustic (Jan 16)
- Re: Secure coding in C (was Re: Administrivia #4883) Liviu Daia (Jan 16)
- Re: Secure coding in C (was Re: Administrivia #4883) Valery Dachev (Jan 17)
- Secure coding in C (was Re: Administrivia #4883) Bennett Todd (Jan 14)
- Re: Administrivia #4883 Marc (Jan 13)
- Netdetect.exe with backdoor? (ICQ) WolF Knox (Jan 15)
- Re: Netdetect.exe with backdoor? (ICQ) Brad Griffin (Jan 15)
- Re: Secure coding in C (was Re: Administrivia #4883) Iván Arce (Jan 14)
- Re: Secure coding in C (was Re: Administrivia #4883) kay (Jan 15)