Vulnerability Development mailing list archives
Re: Secure coding in C (was Re: Administrivia #4883)
From: crowland () CISCO COM (Craig H. Rowland)
Date: Mon, 17 Jan 2000 13:44:24 -0600
Brian Masney wrote:] char *a = something(); ] char *b = something_else(); ] int len = strlen(a) + strlen(b); ] char *c = malloc(len + 1) || die("malloc"); ] (void) strcat(strcpy(c, a), b);I'm partial to strncpy(); strcpy is a known hobgoblin to secure
programming. strncpy() has its problems too (i.e. it doesn't null terminate if the src is too long). I wrote my own SafeStrncpy() function but I think a better choice is the strlcpy() and strlcat() functions that come with OpenBSD. Theo DeRaadt has a presentation on this as well. You should search the OpenBSD site and source tree for more information. The strlcpy() and strlcat() functions take care of a lot of nonsense present in the default C string handling libraries. -- Craig
Current thread:
- Netdetect.exe with backdoor? (ICQ), (continued)
- 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)
- Re: Secure coding in C (was Re: Administrivia #4883) Brian Masney (Jan 16)
- Re: Secure coding in C (was Re: Administrivia #4883) K Martin (Jan 16)
- Re: Secure coding in C (was Re: Administrivia #4883) Paul Cardon (Jan 16)
- Re: Secure coding in C (was Re: Administrivia #4883) K Martin (Jan 17)
- Re: Secure coding in C (was Re: Administrivia #4883) Bennett Todd (Jan 17)
- Re: Secure coding in C (was Re: Administrivia #4883) Aviram Jenik (Jan 16)
- Re: Secure coding in C (was Re: Administrivia #4883) Craig H. Rowland (Jan 17)
- 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)
