|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
Re: Secure coding in C (was Re: Administrivia #4883)
Subject: Re: Secure coding in C (was Re: Administrivia #4883)
From: Craig H. Rowland (crowland
CISCO.COM)
Date: Mon Jan 17 2000 - 13:44:24 CST
- Next message: Solar Eclipse: "Solar Eclipse's Guide To Stealing 100000 Credit Cards in 21 Days"
- Previous message: Jon Hadley: "Re: Netdetect.exe with backdoor? (ICQ)"
- In reply to: K Martin: "Re: Secure coding in C (was Re: Administrivia #4883)"
- Next in thread: Warner Losh: "Re: Secure coding in C (was Re: Administrivia #4883)"
- Reply: Craig H. Rowland: "Re: Secure coding in C (was Re: Administrivia #4883)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> 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
- Next message: Solar Eclipse: "Solar Eclipse's Guide To Stealing 100000 Credit Cards in 21 Days"
- Previous message: Jon Hadley: "Re: Netdetect.exe with backdoor? (ICQ)"
- In reply to: K Martin: "Re: Secure coding in C (was Re: Administrivia #4883)"
- Next in thread: Warner Losh: "Re: Secure coding in C (was Re: Administrivia #4883)"
- Reply: Craig H. Rowland: "Re: Secure coding in C (was Re: Administrivia #4883)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
This archive was generated by hypermail 2b27 : Mon Jan 17 2000 - 22:19:53 CST