diff options
author | archie <archie@FreeBSD.org> | 1998-12-04 22:54:57 +0000 |
---|---|---|
committer | archie <archie@FreeBSD.org> | 1998-12-04 22:54:57 +0000 |
commit | 982e80577dd08945aa2345ebe35e3f50eef9eb48 (patch) | |
tree | e21ff4cbfbcb4097c6cc444d68ddd9a3fd37837f /sys/netatm/uni/unisig_util.c | |
parent | 707b8f68aa118c7396f2a2633751e32477d9ed08 (diff) | |
download | FreeBSD-src-982e80577dd08945aa2345ebe35e3f50eef9eb48.zip FreeBSD-src-982e80577dd08945aa2345ebe35e3f50eef9eb48.tar.gz |
Examine all occurrences of sprintf(), strcat(), and str[n]cpy()
for possible buffer overflow problems. Replaced most sprintf()'s
with snprintf(); for others cases, added terminating NUL bytes where
appropriate, replaced constants like "16" with sizeof(), etc.
These changes include several bug fixes, but most changes are for
maintainability's sake. Any instance where it wasn't "immediately
obvious" that a buffer overflow could not occur was made safer.
Reviewed by: Bruce Evans <bde@zeta.org.au>
Reviewed by: Matthew Dillon <dillon@apollo.backplane.com>
Reviewed by: Mike Spengler <mks@networkcs.com>
Diffstat (limited to 'sys/netatm/uni/unisig_util.c')
-rw-r--r-- | sys/netatm/uni/unisig_util.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/netatm/uni/unisig_util.c b/sys/netatm/uni/unisig_util.c index 6a3afb8..a3a2ab2 100644 --- a/sys/netatm/uni/unisig_util.c +++ b/sys/netatm/uni/unisig_util.c @@ -23,7 +23,7 @@ * Copies of this Software may be made, however, the above copyright * notice must be reproduced on all copies. * - * @(#) $Id: unisig_util.c,v 1.2 1998/09/17 09:35:02 phk Exp $ + * @(#) $Id: unisig_util.c,v 1.3 1998/10/31 20:07:01 phk Exp $ * */ @@ -42,7 +42,7 @@ #include <netatm/uni/unisig_msg.h> #ifndef lint -__RCSID("@(#) $Id: unisig_util.c,v 1.2 1998/09/17 09:35:02 phk Exp $"); +__RCSID("@(#) $Id: unisig_util.c,v 1.3 1998/10/31 20:07:01 phk Exp $"); #endif @@ -303,7 +303,8 @@ unisig_addr_print(p) * two-digit hex representation of the * NSAP byte in the output buffer */ - sprintf(t_buff, "%x", *cp + 512); + snprintf(t_buff, sizeof(t_buff), + "%x", *cp + 512); strcpy(op, &t_buff[strlen(t_buff)-2]); op++; op++; cp++; @@ -325,7 +326,8 @@ unisig_addr_print(p) * Print the IA5 characters of the E.164 address */ for(i=0; i<p->address_length; i++) { - sprintf(&strbuff[strlen(strbuff)], "%c", + snprintf(strbuff + strlen(strbuff), + sizeof(strbuff) - strlen(strbuff), "%c", ((Atm_addr_e164 *)p->address)->aae_addr[i]); } break; @@ -346,7 +348,7 @@ unisig_addr_print(p) /* * Print the address as two words xxxxx.yyyyyyyy */ - sprintf(strbuff, "%x.%x", u1.w, u2.w); + snprintf(strbuff, sizeof(strbuff), "%x.%x", u1.w, u2.w); break; case T_ATM_ABSENT: |