|
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: Marco Walther (marcow
JENA.ENG.SUN.COM)
Date: Fri Jan 14 2000 - 15:48:50 CST
- Next message: Iván Arce: "Re: Secure coding in C (was Re: Administrivia #4883)"
- Previous message: Bennett Todd: "Re: Secure coding in C (was Re: Administrivia #4883)"
- In reply to: Bennett Todd: "Secure coding in C (was Re: Administrivia #4883)"
- Next in thread: Bennett Todd: "Re: Secure coding in C (was Re: Administrivia #4883)"
- Reply: Marco Walther: "Re: Secure coding in C (was Re: Administrivia #4883)"
- Reply: Liviu Daia: "Re: Secure coding in C (was Re: Administrivia #4883)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>>>>> "BT" == Bennett Todd <bet
RAHUL.NET> writes:
BT> For a specific case, is there any security hole directly implied by
BT> this C fragment, assuming attackers could control the contents of a
BT> and b?
BT> char *a = something();
BT> char *b = something_else();
BT> int len = strlen(a) + strlen(b);
BT> char *c = malloc(len + 1) || die("malloc");
BT> (void) strcat(strcpy(c, a), b);
I don't see any problems here;-)
BT> BTW, what I ended up coding instead of that last line (as it grew
BT> way more complex) was equivalent to:
BT> snprintf(c, len, "%s%s", a, b) > 0 || die "snprintf";
You're dead! Use (*a == '\0' && *b == '\0') and snprintf() returns `0'!!
Good lock;-)
-- Marco
BT> -Bennett
--
- Next message: Iván Arce: "Re: Secure coding in C (was Re: Administrivia #4883)"
- Previous message: Bennett Todd: "Re: Secure coding in C (was Re: Administrivia #4883)"
- In reply to: Bennett Todd: "Secure coding in C (was Re: Administrivia #4883)"
- Next in thread: Bennett Todd: "Re: Secure coding in C (was Re: Administrivia #4883)"
- Reply: Marco Walther: "Re: Secure coding in C (was Re: Administrivia #4883)"
- Reply: Liviu Daia: "Re: Secure coding in C (was Re: Administrivia #4883)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
This archive was generated by hypermail 2b27 : Fri Jan 14 2000 - 16:30:46 CST