diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-05-06 07:28:40 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-05-06 07:28:40 +0000 |
commit | 22f9e05af0fd8d4f6850afdc2025b10f969c1400 (patch) | |
tree | b2d354def85efa5bf9319769883db4201ab1f246 /sys | |
parent | 9c7db1c3fa6774fd0192cfd4e978c703edbf1794 (diff) |
string cleaning; tedu ok
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_kthread.c | 4 | ||||
-rw-r--r-- | sys/kern/kgdb_stub.c | 6 | ||||
-rw-r--r-- | sys/net/if_spppsubr.c | 14 | ||||
-rw-r--r-- | sys/netinet/ip_ipsp.c | 116 | ||||
-rw-r--r-- | sys/netinet/ip_ipsp.h | 4 | ||||
-rw-r--r-- | sys/netinet/ip_mroute.c | 5 |
6 files changed, 83 insertions, 66 deletions
diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c index e384832c838..ce81dc9342a 100644 --- a/sys/kern/kern_kthread.c +++ b/sys/kern/kern_kthread.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_kthread.c,v 1.18 2002/06/11 06:35:18 art Exp $ */ +/* $OpenBSD: kern_kthread.c,v 1.19 2003/05/06 07:28:38 deraadt Exp $ */ /* $NetBSD: kern_kthread.c,v 1.3 1998/12/22 21:21:36 kleink Exp $ */ /*- @@ -89,7 +89,7 @@ kthread_create(void (*func)(void *), void *arg, /* Name it as specified. */ va_start(ap, fmt); - vsprintf(p2->p_comm, fmt, ap); + vsnprintf(p2->p_comm, sizeof p2->p_comm, fmt, ap); va_end(ap); /* All done! */ diff --git a/sys/kern/kgdb_stub.c b/sys/kern/kgdb_stub.c index 60be586a451..52f02dcff4a 100644 --- a/sys/kern/kgdb_stub.c +++ b/sys/kern/kgdb_stub.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kgdb_stub.c,v 1.4 2002/03/14 03:16:09 millert Exp $ */ +/* $OpenBSD: kgdb_stub.c,v 1.5 2003/05/06 07:28:38 deraadt Exp $ */ /* $NetBSD: kgdb_stub.c,v 1.6 1998/08/30 20:30:57 scottr Exp $ */ /* @@ -379,7 +379,7 @@ kgdb_trap(type, regs) kgdb_active = 1; } else { /* Tell remote host that an exception has occurred. */ - sprintf(buffer, "S%02x", kgdb_signal(type)); + snprintf(buffer, sizeof buffer, "S%02x", kgdb_signal(type)); kgdb_send(buffer); } @@ -407,7 +407,7 @@ kgdb_trap(type, regs) * knowing if we're in or out of this loop * when he issues a "remote-signal". */ - sprintf(buffer, "S%02x", kgdb_signal(type)); + snprintf(buffer, sizeof buffer, "S%02x", kgdb_signal(type)); kgdb_send(buffer); continue; diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c index 25856a5ff72..3076cd69c21 100644 --- a/sys/net/if_spppsubr.c +++ b/sys/net/if_spppsubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_spppsubr.c,v 1.17 2003/01/07 09:00:33 kjc Exp $ */ +/* $OpenBSD: if_spppsubr.c,v 1.18 2003/05/06 07:28:39 deraadt Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. * Keepalive protocol implemented in both Cisco and PPP modes. @@ -4109,7 +4109,7 @@ sppp_cp_type_name(u_char type) case ECHO_REPLY: return "echo-reply"; case DISC_REQ: return "discard-req"; } - sprintf (buf, "0x%x", type); + snprintf (buf, sizeof buf, "0x%x", type); return buf; } @@ -4132,7 +4132,7 @@ sppp_auth_type_name(u_short proto, u_char type) case PAP_NAK: return "nak"; } } - sprintf (buf, "0x%x", type); + snprintf (buf, sizeof buf, "0x%x", type); return buf; } @@ -4149,7 +4149,7 @@ sppp_lcp_opt_name(u_char opt) case LCP_OPT_PROTO_COMP: return "proto-comp"; case LCP_OPT_ADDR_COMP: return "addr-comp"; } - sprintf (buf, "0x%x", opt); + snprintf (buf, sizeof buf, "0x%x", opt); return buf; } @@ -4162,7 +4162,7 @@ sppp_ipcp_opt_name(u_char opt) case IPCP_OPT_COMPRESSION: return "compression"; case IPCP_OPT_ADDRESS: return "address"; } - sprintf (buf, "0x%x", opt); + snprintf (buf, sizeof buf, "0x%x", opt); return buf; } @@ -4207,7 +4207,7 @@ sppp_proto_name(u_short proto) case PPP_PAP: return "pap"; case PPP_CHAP: return "chap"; } - sprintf(buf, "0x%x", (unsigned)proto); + snprintf(buf, sizeof buf, "0x%x", (unsigned)proto); return buf; } @@ -4240,7 +4240,7 @@ HIDE const char * sppp_dotted_quad(u_long addr) { static char s[16]; - sprintf(s, "%d.%d.%d.%d", + snprintf(s, sizeof s, "%d.%d.%d.%d", (int)((addr >> 24) & 0xff), (int)((addr >> 16) & 0xff), (int)((addr >> 8) & 0xff), diff --git a/sys/netinet/ip_ipsp.c b/sys/netinet/ip_ipsp.c index 8ef0062dca2..ec303b2d63c 100644 --- a/sys/netinet/ip_ipsp.c +++ b/sys/netinet/ip_ipsp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipsp.c,v 1.150 2002/11/19 18:34:41 jason Exp $ */ +/* $OpenBSD: ip_ipsp.c,v 1.151 2003/05/06 07:28:39 deraadt Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr), @@ -848,9 +848,8 @@ tdb_init(struct tdb *tdbp, u_int16_t alg, struct ipsecinit *ii) * Print TDB information on a buffer. */ int -ipsp_print_tdb(struct tdb *tdb, char *buffer) +ipsp_print_tdb(struct tdb *tdb, char *buffer, size_t buflen) { - int l, i, k; struct ctlname ipspflags[] = { { "unique", TDBF_UNIQUE }, { "invalid", TDBF_INVALID }, @@ -862,53 +861,59 @@ ipsp_print_tdb(struct tdb *tdb, char *buffer) { "skipcrypto", TDBF_SKIPCRYPTO }, { "usedtunnel", TDBF_USEDTUNNEL }, }; + int l, i, k; - l = sprintf(buffer, "SPI = %08x, Destination = %s, Sproto = %u\n", - ntohl(tdb->tdb_spi), ipsp_address(tdb->tdb_dst), tdb->tdb_sproto); - - l += sprintf(buffer + l, "\tEstablished %d seconds ago\n", - time.tv_sec - tdb->tdb_established); - - l += sprintf(buffer + l, "\tSource = %s", ipsp_address(tdb->tdb_src)); + l = snprintf(buffer, buflen, + "SPI = %08x, Destination = %s, Sproto = %u\n" + "\tEstablished %d seconds ago\n" + "\tSource = %s", + ntohl(tdb->tdb_spi), ipsp_address(tdb->tdb_dst), tdb->tdb_sproto, + time.tv_sec - tdb->tdb_established, + ipsp_address(tdb->tdb_src)); if (tdb->tdb_proxy.sa.sa_family) - l += sprintf(buffer + l, ", Proxy = %s\n", - ipsp_address(tdb->tdb_proxy)); - else - l += sprintf(buffer + l, "\n"); + l += snprintf(buffer + l, buflen - l, + ", Proxy = %s", ipsp_address(tdb->tdb_proxy)); + l += snprintf(buffer + l, buflen - l, "\n"); if (tdb->tdb_mtu && tdb->tdb_mtutimeout > time.tv_sec) - l += sprintf(buffer + l, "\tMTU: %d, expires in %llu seconds\n", + l += snprintf(buffer + l, buflen - l, + "\tMTU: %d, expires in %llu seconds\n", tdb->tdb_mtu, tdb->tdb_mtutimeout - time.tv_sec); if (tdb->tdb_local_cred) - l += sprintf(buffer + l, "\tLocal credential type %d\n", + l += snprintf(buffer + l, buflen - l, + "\tLocal credential type %d\n", ((struct ipsec_ref *) tdb->tdb_local_cred)->ref_type); if (tdb->tdb_remote_cred) - l += sprintf(buffer + l, "\tRemote credential type %d\n", + l += snprintf(buffer + l, buflen - l, + "\tRemote credential type %d\n", ((struct ipsec_ref *) tdb->tdb_remote_cred)->ref_type); if (tdb->tdb_local_auth) - l += sprintf(buffer + l, "\tLocal auth type %d\n", + l += snprintf(buffer + l, buflen - l, + "\tLocal auth type %d\n", ((struct ipsec_ref *) tdb->tdb_local_auth)->ref_type); if (tdb->tdb_remote_auth) - l += sprintf(buffer + l, "\tRemote auth type %d\n", + l += snprintf(buffer + l, buflen - l, + "\tRemote auth type %d\n", ((struct ipsec_ref *) tdb->tdb_remote_auth)->ref_type); - l += sprintf(buffer + l, "\tFlags (%08x) = <", tdb->tdb_flags); + l += snprintf(buffer + l, buflen - l, + "\tFlags (%08x) = <", tdb->tdb_flags); if ((tdb->tdb_flags & ~(TDBF_TIMER | TDBF_BYTES | TDBF_ALLOCATIONS | TDBF_FIRSTUSE | TDBF_SOFT_TIMER | TDBF_SOFT_BYTES | TDBF_SOFT_FIRSTUSE | TDBF_SOFT_ALLOCATIONS)) == 0) - l += sprintf(buffer + l, "none>\n"); + l += snprintf(buffer + l, buflen - l, "none>\n"); else { for (k = 0, i = 0; k < sizeof(ipspflags) / sizeof(struct ctlname); k++) { if (tdb->tdb_flags & ipspflags[k].ctl_type) { - l += sprintf(buffer + l, "%s,", - ipspflags[k].ctl_name); + l += snprintf(buffer + l, buflen - l, + "%s,", ipspflags[k].ctl_name); i = 1; } } @@ -916,94 +921,103 @@ ipsp_print_tdb(struct tdb *tdb, char *buffer) /* If we added flags, remove trailing comma. */ if (i) l--; - l += sprintf(buffer + l, ">\n"); + l += snprintf(buffer + l, buflen - l, ">\n"); } - l += sprintf(buffer + l, "\tCrypto ID: %llu\n", tdb->tdb_cryptoid); + l += snprintf(buffer + l, buflen - l, + "\tCrypto ID: %llu\n", tdb->tdb_cryptoid); if (tdb->tdb_xform) - l += sprintf(buffer + l, "\txform = <%s>\n", + l += snprintf(buffer + l, buflen - l, + "\txform = <%s>\n", tdb->tdb_xform->xf_name); if (tdb->tdb_encalgxform) - l += sprintf(buffer + l, "\t\tEncryption = <%s>\n", + l += snprintf(buffer + l, buflen - l, + "\t\tEncryption = <%s>\n", tdb->tdb_encalgxform->name); if (tdb->tdb_authalgxform) - l += sprintf(buffer + l, "\t\tAuthentication = <%s>\n", + l += snprintf(buffer + l, buflen - l, + "\t\tAuthentication = <%s>\n", tdb->tdb_authalgxform->name); if (tdb->tdb_compalgxform) - l += sprintf(buffer + l, "\t\tCompression = <%s>\n", + l += snprintf(buffer + l, buflen - l, + "\t\tCompression = <%s>\n", tdb->tdb_compalgxform->name); if (tdb->tdb_onext) - l += sprintf(buffer + l, + l += snprintf(buffer + l, buflen - l, "\tNext SA: SPI = %08x, Destination = %s, Sproto = %u\n", ntohl(tdb->tdb_onext->tdb_spi), ipsp_address(tdb->tdb_onext->tdb_dst), tdb->tdb_onext->tdb_sproto); if (tdb->tdb_inext) - l += sprintf(buffer + l, "\tPrevious SA: SPI = %08x, " + l += snprintf(buffer + l, buflen - l, + "\tPrevious SA: SPI = %08x, " "Destination = %s, Sproto = %u\n", ntohl(tdb->tdb_inext->tdb_spi), ipsp_address(tdb->tdb_inext->tdb_dst), tdb->tdb_inext->tdb_sproto); - l += sprintf(buffer + l, "\t%llu bytes processed by this SA\n", + l += snprintf(buffer + l, buflen - l, + "\t%llu bytes processed by this SA\n", tdb->tdb_cur_bytes); if (tdb->tdb_last_used) - l += sprintf(buffer + l, "\tLast used %llu seconds ago\n", + l += snprintf(buffer + l, buflen - l, + "\tLast used %llu seconds ago\n", time.tv_sec - tdb->tdb_last_used); if (tdb->tdb_last_marked) - l += sprintf(buffer + l, + l += snprintf(buffer + l, buflen - l, "\tLast marked/unmarked %llu seconds ago\n", time.tv_sec - tdb->tdb_last_marked); - l += sprintf(buffer + l, "\tExpirations:\n"); + l += snprintf(buffer + l, buflen - l, + "\tExpirations:\n"); if (tdb->tdb_flags & TDBF_TIMER) - l += sprintf(buffer + l, + l += snprintf(buffer + l, buflen -l, "\t\tHard expiration(1) in %llu seconds\n", tdb->tdb_established + tdb->tdb_exp_timeout - time.tv_sec); if (tdb->tdb_flags & TDBF_SOFT_TIMER) - l += sprintf(buffer + l, + l += snprintf(buffer + l, buflen -l, "\t\tSoft expiration(1) in %llu seconds\n", tdb->tdb_established + tdb->tdb_soft_timeout - time.tv_sec); if (tdb->tdb_flags & TDBF_BYTES) - l += sprintf(buffer + l, + l += snprintf(buffer + l, buflen -l, "\t\tHard expiration after %llu bytes\n", tdb->tdb_exp_bytes); if (tdb->tdb_flags & TDBF_SOFT_BYTES) - l += sprintf(buffer + l, + l += snprintf(buffer + l, buflen -l, "\t\tSoft expiration after %llu bytes\n", tdb->tdb_soft_bytes); if (tdb->tdb_flags & TDBF_ALLOCATIONS) - l += sprintf(buffer + l, + l += snprintf(buffer + l, buflen -l, "\t\tHard expiration after %u flows\n", tdb->tdb_exp_allocations); if (tdb->tdb_flags & TDBF_SOFT_ALLOCATIONS) - l += sprintf(buffer + l, + l += snprintf(buffer + l, buflen -l, "\t\tSoft expiration after %u flows\n", tdb->tdb_soft_allocations); if (tdb->tdb_flags & TDBF_FIRSTUSE) { if (tdb->tdb_first_use) - l += sprintf(buffer + l, + l += snprintf(buffer + l, buflen -l, "\t\tHard expiration(2) in %llu seconds\n", (tdb->tdb_first_use + tdb->tdb_exp_first_use) - time.tv_sec); else - l += sprintf(buffer + l, + l += snprintf(buffer + l, buflen -l, "\t\tHard expiration in %llu seconds " "after first use\n", tdb->tdb_exp_first_use); @@ -1011,12 +1025,12 @@ ipsp_print_tdb(struct tdb *tdb, char *buffer) if (tdb->tdb_flags & TDBF_SOFT_FIRSTUSE) { if (tdb->tdb_first_use) - l += sprintf(buffer + l, + l += snprintf(buffer + l, buflen -l, "\t\tSoft expiration(2) in %llu seconds\n", (tdb->tdb_first_use + tdb->tdb_soft_first_use) - time.tv_sec); else - l += sprintf(buffer + l, + l += snprintf(buffer + l, buflen -l, "\t\tSoft expiration in %llu seconds " "after first use\n", tdb->tdb_soft_first_use); } @@ -1025,9 +1039,9 @@ ipsp_print_tdb(struct tdb *tdb, char *buffer) (TDBF_TIMER | TDBF_SOFT_TIMER | TDBF_BYTES | TDBF_SOFT_ALLOCATIONS | TDBF_ALLOCATIONS | TDBF_SOFT_BYTES | TDBF_FIRSTUSE | TDBF_SOFT_FIRSTUSE))) - l += sprintf(buffer + l, "\t\t(none)\n"); + l += snprintf(buffer + l, buflen -l, "\t\t(none)\n"); - l += sprintf(buffer + l, "\n"); + l += snprintf(buffer + l, buflen -l, "\n"); return l; } @@ -1050,7 +1064,8 @@ ipsp_kern(int off, char **bufp, int len) if (off == 0) { kernfs_epoch++; - l = sprintf(buffer, "Hashmask: %d, policy entries: %d\n", + l = snprintf(buffer, sizeof buffer, + "Hashmask: %d, policy entries: %d\n", tdb_hashmask, ipsec_in_use); return l; } @@ -1063,7 +1078,7 @@ ipsp_kern(int off, char **bufp, int len) for (tdb = tdbh[i]; tdb; tdb = tdb->tdb_hnext) { if (tdb->tdb_epoch != kernfs_epoch) { tdb->tdb_epoch = kernfs_epoch; - l = ipsp_print_tdb(tdb, buffer); + l = ipsp_print_tdb(tdb, buffer, sizeof buffer); splx(s); return l; } @@ -1141,7 +1156,8 @@ inet_ntoa4(struct in_addr ina) static int i = 3; i = (i + 1) % 4; - sprintf(buf[i], "%d.%d.%d.%d", ucp[0] & 0xff, ucp[1] & 0xff, + snprintf(buf[i], sizeof buf[0], "%d.%d.%d.%d", + ucp[0] & 0xff, ucp[1] & 0xff, ucp[2] & 0xff, ucp[3] & 0xff); return (buf[i]); } diff --git a/sys/netinet/ip_ipsp.h b/sys/netinet/ip_ipsp.h index 7a6228af4d9..f429e13559d 100644 --- a/sys/netinet/ip_ipsp.h +++ b/sys/netinet/ip_ipsp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipsp.h,v 1.121 2002/06/09 16:26:10 itojun Exp $ */ +/* $OpenBSD: ip_ipsp.h,v 1.122 2003/05/06 07:28:39 deraadt Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr), @@ -659,7 +659,7 @@ extern struct m_tag *ipsp_parse_headers(struct mbuf *, int, u_int8_t); extern int ipsp_ref_match(struct ipsec_ref *, struct ipsec_ref *); extern ssize_t ipsec_hdrsz(struct tdb *); extern void ipsec_adjust_mtu(struct mbuf *, u_int32_t); -extern int ipsp_print_tdb(struct tdb *, char *); +extern int ipsp_print_tdb(struct tdb *, char *, size_t); extern struct ipsec_acquire *ipsec_get_acquire(u_int32_t); extern int ipsp_aux_match(struct ipsec_ref *, struct ipsec_ref *, struct ipsec_ref *, struct ipsec_ref *, struct ipsec_ref *, diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index 36aa36caf3e..ce870d4b16c 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_mroute.c,v 1.28 2002/08/28 15:43:03 pefo Exp $ */ +/* $OpenBSD: ip_mroute.c,v 1.29 2003/05/06 07:28:39 deraadt Exp $ */ /* $NetBSD: ip_mroute.c,v 1.27 1996/05/07 02:40:50 thorpej Exp $ */ /* @@ -605,7 +605,8 @@ add_vif(m) /* Create a fake encapsulation interface. */ ifp = (struct ifnet *)malloc(sizeof(*ifp), M_MRTABLE, M_WAITOK); bzero(ifp, sizeof(*ifp)); - sprintf(ifp->if_xname, "mdecap%d", vifcp->vifc_vifi); + snprintf(ifp->if_xname, sizeof ifp->if_xname, + "mdecap%d", vifcp->vifc_vifi); /* Prepare cached route entry. */ bzero(&vifp->v_route, sizeof(vifp->v_route)); |