Vulnerability Development mailing list archives
Re: Secure coding in C (was Re: Administrivia #4883)
From: mikael.olsson () ENTERNET SE (Mikael Olsson)
Date: Fri, 21 Jan 2000 12:12:35 +0100
Blue Boar wrote:
So, the test above was to take a 10 character buffer, and try to use snprintf to cram something longer in it. If snprintf was broken like the man page suggested, then the 10th character would have been the letter l from "really", instead of a zero as it should be. However, it works just fine, and the 10th character is a 0. And that's the right thing.. it just means the documentation needs an update. :)
It also means that someone is going to assume that they can use snprintf() without any precautions, since "their code will only ever run on solaris" until someone decides to port it, and forgets about fixing the snprintf() SNAFUs. Myself, I always end all my string ops by NULing the last character in the buffer. That way I _KNOW_ I'm safe. char mybuf[10]; strncpy(mybuf, unknowninputstring, sizeof(mybuf)); mybuf[sizeof(mybuf)-1]='\0'; Oh, and by the way, these few lines placed in a commonly included help file help a long way: #define strcpy __do_NOT_use_strcpy__ #define sprintf __do_NOT_use_sprintf__ etc etc etc ... All's well :-) /Mike -- Mikael Olsson, EnterNet Sweden AB, Box 393, S-891 28 ÖRNSKÖLDSVIK Phone: +46 (0)660 105 50 Fax: +46 (0)660 122 50 Mobile: +46 (0)70 248 00 33 WWW: http://www.enternet.se E-mail: mikael.olsson () enternet se
Current thread:
- Solar Eclipse's Guide To Stealing 100000 Credit Cards in 21 Days, (continued)
- Solar Eclipse's Guide To Stealing 100000 Credit Cards in 21 Days Solar Eclipse (Jan 17)
- Re: Solar Eclipse's Guide To Stealing 100000 Credit Cards in 21 Days Blue Boar (Jan 17)
- Re: Solar Eclipse's Guide To Stealing 100000 Credit Cards in 21 Days kay (Jan 18)
- Re: Solar Eclipse's Guide To Stealing 100000 Credit Cards in 21Days Blue Boar (Jan 18)
- e-commerce site security (was: Re: Solar Eclipse's Guide To Stealing 100000 Credit Cards in 21 Days) Jon Paul, Nollmann (Jan 18)
- Re: Secure coding in C (was Re: Administrivia #4883) Warner Losh (Jan 17)
- Re: Secure coding in C (was Re: Administrivia #4883) Tellier, Brock (Jan 20)
- Re: Secure coding in C (was Re: Administrivia #4883) Marco Walther (Jan 20)
- Re: Secure coding in C (was Re: Administrivia #4883) Seth R Arnold (Jan 21)
- Re: Secure coding in C (was Re: Administrivia #4883) Blue Boar (Jan 21)
- Re: Secure coding in C (was Re: Administrivia #4883) Mikael Olsson (Jan 21)
- Re: Secure coding in C (was Re: Administrivia #4883) Marco Walther (Jan 21)
- Re: Secure coding in C (was Re: Administrivia #4883) CyberPsychotic (Jan 22)
- Re: Secure coding in C (was Re: Administrivia #4883) Marc Esipovich (Jan 21)
- Generalized List of Threats and Vulnerabilities Dave Drake (Jan 21)
- Re: Generalized List of Threats and Vulnerabilities Seth R Arnold (Jan 21)
- Re: Generalized List of Threats and Vulnerabilities Crispin Cowan (Jan 23)
- Re: Generalized List of Threats and Vulnerabilities John Duksta (Jan 21)
- Administrivia #5218 Blue Boar (Jan 21)
- Re: Administrivia #5218 Imran Ghory (Jan 22)
- Re: Administrivia #5218 kjkotas (Jan 22)