diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-03-13 09:09:52 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-03-13 09:09:52 +0000 |
commit | cd64a50f546ecbfd25035373ee745bd04e4e5905 (patch) | |
tree | 86a1452cec538b8f5259a45745e95cd1161d04e7 /sbin/routed | |
parent | 6153e3b8d9aedd43b1300c4d60217039c9485e02 (diff) |
lots of sprintf -> snprintf and strcpy -> strlcpy; checked by tedu
Diffstat (limited to 'sbin/routed')
-rw-r--r-- | sbin/routed/parms.c | 7 | ||||
-rw-r--r-- | sbin/routed/table.c | 5 | ||||
-rw-r--r-- | sbin/routed/trace.c | 20 |
3 files changed, 19 insertions, 13 deletions
diff --git a/sbin/routed/parms.c b/sbin/routed/parms.c index 994810f7e88..5e2d110e448 100644 --- a/sbin/routed/parms.c +++ b/sbin/routed/parms.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parms.c,v 1.7 2002/08/08 14:00:24 aaron Exp $ */ +/* $OpenBSD: parms.c,v 1.8 2003/03/13 09:09:27 deraadt Exp $ */ /* * Copyright (c) 1983, 1993 @@ -386,13 +386,14 @@ parse_parms(char *line) || tok[3] == '\0' || strlen(tok) > IFNAMSIZ+3) break; - strcpy(parm.parm_name, tok+3); + strlcpy(parm.parm_name, tok+3, sizeof parm.parm_name); } else if (PARSE("passwd")) { if (tok[7] == '\0' || strlen(tok) > RIP_AUTH_PW_LEN+7) break; - strcpy(parm.parm_passwd, tok+7); + strlcpy(parm.parm_passwd, tok+7, + sizeof parm.parm_passwd); } else if (PARS("no_ag")) { parm.parm_int_state |= (IS_NO_AG | IS_NO_SUPER_AG); diff --git a/sbin/routed/table.c b/sbin/routed/table.c index 44a82e2555f..1f0075ea849 100644 --- a/sbin/routed/table.c +++ b/sbin/routed/table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: table.c,v 1.9 2003/03/13 06:10:49 deraadt Exp $ */ +/* $OpenBSD: table.c,v 1.10 2003/03/13 09:09:27 deraadt Exp $ */ /* * Copyright (c) 1983, 1988, 1993 @@ -1088,7 +1088,8 @@ read_rt(void) continue; } - strcpy(str, rtm_type_name(m.r.rtm.rtm_type)); + strlcpy(str, rtm_type_name(m.r.rtm.rtm_type), + sizeof str); strp = &str[strlen(str)]; if (m.r.rtm.rtm_type <= RTM_CHANGE) strp += sprintf(strp," from pid %ld", (long)m.r.rtm.rtm_pid); diff --git a/sbin/routed/trace.c b/sbin/routed/trace.c index 45ef94f5189..10d4cc5a810 100644 --- a/sbin/routed/trace.c +++ b/sbin/routed/trace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trace.c,v 1.9 2001/09/05 22:32:38 deraadt Exp $ */ +/* $OpenBSD: trace.c,v 1.10 2003/03/13 09:09:27 deraadt Exp $ */ /* $NetBSD: trace.c,v 1.13 1995/06/20 22:28:03 christos Exp $ */ /* @@ -37,7 +37,7 @@ #if !defined(lint) static char sccsid[] = "@(#)trace.c 8.1 (Berkeley) 6/5/93"; #else -static char rcsid[] = "$OpenBSD: trace.c,v 1.9 2001/09/05 22:32:38 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: trace.c,v 1.10 2003/03/13 09:09:27 deraadt Exp $"; #endif #define RIPCMDS @@ -74,13 +74,13 @@ naddr_ntoa(naddr a) static struct { char str[16]; /* xxx.xxx.xxx.xxx\0 */ } bufs[NUM_BUFS]; - char *s; struct in_addr addr; addr.s_addr = a; - s = strcpy(bufs[bufno].str, inet_ntoa(addr)); + strlcpy(bufs[bufno].str, inet_ntoa(addr), + sizeof bufs[bufno].str); bufno = (bufno+1) % NUM_BUFS; - return s; + return bufs[bufno].str; #undef NUM_BUFS } @@ -344,8 +344,10 @@ addrname(naddr addr, /* in network byte order */ naddr dmask; int i; - s = strcpy(bufs[bufno].str, naddr_ntoa(addr)); + strlcpy(bufs[bufno].str, naddr_ntoa(addr), + sizeof bufs[bufno].str); bufno = (bufno+1) % NUM_BUFS; + s = bufs[bufno].str; if (force == 1 || (force == 0 && mask != std_mask(addr))) { sp = &s[strlen(s)]; @@ -485,8 +487,10 @@ trace_pair(naddr dst, +3*4+3+1]; /* "xxx.xxx.xxx.xxx" */ int i; - i = sprintf(buf, "%-16s-->", addrname(dst, mask, 0)); - (void)sprintf(&buf[i], "%-*s", 15+20-MAX(20,i), gate); + i = snprintf(buf, sizeof buf, "%-16s-->", addrname(dst, mask, 0)); + if (i >= sizeof buf) + return buf; + (void)snprintf(&buf[i], sizeof buf - i, "%-*s", 15+20-MAX(20,i), gate); return buf; } |