diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-05-03 21:15:12 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-05-03 21:15:12 +0000 |
commit | 492edca4204c3a1bbefa82cd0298b4bc5044d58c (patch) | |
tree | cc04c242a406e06fa0b22325e0c00875a2d3ca78 /sys | |
parent | 59195b3dfca23fbd322412cb1fc7f5fc476edee8 (diff) |
string fixes; tedu ok
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/exec_script.c | 8 | ||||
-rw-r--r-- | sys/kern/kern_malloc.c | 21 | ||||
-rw-r--r-- | sys/kern/kern_sig.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_sysctl.c | 5 | ||||
-rw-r--r-- | sys/kern/subr_autoconf.c | 4 | ||||
-rw-r--r-- | sys/kern/subr_userconf.c | 4 | ||||
-rw-r--r-- | sys/net/if_bridge.c | 4 | ||||
-rw-r--r-- | sys/net/if_enc.c | 4 | ||||
-rw-r--r-- | sys/net/if_faith.c | 4 | ||||
-rw-r--r-- | sys/net/if_gif.c | 5 | ||||
-rw-r--r-- | sys/net/if_loop.c | 4 | ||||
-rw-r--r-- | sys/net/if_pflog.c | 4 | ||||
-rw-r--r-- | sys/net/if_pfsync.c | 4 | ||||
-rw-r--r-- | sys/net/if_ppp.c | 4 | ||||
-rw-r--r-- | sys/net/if_sl.c | 5 | ||||
-rw-r--r-- | sys/net/if_strip.c | 5 | ||||
-rw-r--r-- | sys/net/if_tun.c | 4 | ||||
-rw-r--r-- | sys/net/if_vlan.c | 4 |
18 files changed, 53 insertions, 44 deletions
diff --git a/sys/kern/exec_script.c b/sys/kern/exec_script.c index 1d6ce8ed3c9..702ea6345ac 100644 --- a/sys/kern/exec_script.c +++ b/sys/kern/exec_script.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_script.c,v 1.17 2002/09/18 22:01:15 art Exp $ */ +/* $OpenBSD: exec_script.c,v 1.18 2003/05/03 21:14:59 deraadt Exp $ */ /* $NetBSD: exec_script.c,v 1.13 1996/02/04 02:15:06 christos Exp $ */ /* @@ -203,10 +203,10 @@ check_shell: MALLOC(shellargp, char **, 4 * sizeof(char *), M_EXEC, M_WAITOK); tmpsap = shellargp; *tmpsap = malloc(shellnamelen + 1, M_EXEC, M_WAITOK); - strcpy(*tmpsap++, shellname); + strlcpy(*tmpsap++, shellname, shellnamelen + 1); if (shellarg != NULL) { *tmpsap = malloc(shellarglen + 1, M_EXEC, M_WAITOK); - strcpy(*tmpsap++, shellarg); + strlcpy(*tmpsap++, shellarg, shellarglen + 1); } *tmpsap = malloc(MAXPATHLEN, M_EXEC, M_WAITOK); #ifdef FDSCRIPTS @@ -221,7 +221,7 @@ check_shell: #endif #ifdef FDSCRIPTS } else - sprintf(*tmpsap++, "/dev/fd/%d", epp->ep_fd); + snprintf(*tmpsap++, MAXPATHLEN, "/dev/fd/%d", epp->ep_fd); #endif *tmpsap = NULL; diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index f72652b8f24..91a7ad9e0a3 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_malloc.c,v 1.50 2003/04/10 08:48:34 tedu Exp $ */ +/* $OpenBSD: kern_malloc.c,v 1.51 2003/05/03 21:14:59 deraadt Exp $ */ /* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */ /* @@ -536,9 +536,12 @@ sysctl_malloc(name, namelen, oldp, oldlenp, newp, newlen, p) if (buckstring_init == 0) { buckstring_init = 1; bzero(buckstring, sizeof(buckstring)); - for (siz = 0, i = MINBUCKET; i < MINBUCKET + 16; i++) - siz += sprintf(buckstring + siz, - "%d,", (u_int)(1<<i)); + for (siz = 0, i = MINBUCKET; i < MINBUCKET + 16; i++) { + snprintf(buckstring + siz, + sizeof buckstring - siz, + "%d,", (u_int)(1<<i)); + siz += strlen(buckstring + siz); + } /* Remove trailing comma */ if (siz) buckstring[siz - 1] = '\0'; @@ -575,10 +578,12 @@ sysctl_malloc(name, namelen, oldp, oldlenp, newp, newlen, p) } memall = malloc(totlen + M_LAST, M_SYSCTL, M_WAITOK); bzero(memall, totlen + M_LAST); - for (siz = 0, i = 0; i < M_LAST; i++) - siz += sprintf(memall + siz, "%s,", - memname[i] ? memname[i] : ""); - + for (siz = 0, i = 0; i < M_LAST; i++) { + snprintf(memall + siz, + totlen + M_LAST - siz, + "%s,", memname[i] ? memname[i] : ""); + siz += strlen(memall + siz); + } /* Remove trailing comma */ if (siz) memall[siz - 1] = '\0'; diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 83a27b631c7..df8abc28e3d 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.61 2002/10/01 17:33:39 art Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.62 2003/05/03 21:14:59 deraadt Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -1309,7 +1309,7 @@ coredump(p) cred->cr_uid = p->p_cred->p_ruid; cred->cr_gid = p->p_cred->p_rgid; - sprintf(name, "%s.core", p->p_comm); + snprintf(name, sizeof name, "%s.core", p->p_comm); NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, p); error = vn_open(&nd, O_CREAT | FWRITE | O_NOFOLLOW, S_IRUSR | S_IWUSR); diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 338027df657..62a58eeaea2 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.80 2003/04/25 20:06:41 grange Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.81 2003/05/03 21:14:59 deraadt Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -1284,8 +1284,9 @@ sysctl_diskinit(update, p) for (dk = TAILQ_FIRST(&disklist), i = 0, l = 0; dk; dk = TAILQ_NEXT(dk, dk_link), i++) { - l += sprintf(disknames + l, "%s,", + snprintf(disknames + l, tlen - l, "%s,", dk->dk_name ? dk->dk_name : ""); + l += strlen(disknames + l); sdk = diskstats + i; sdk->ds_busy = dk->dk_busy; sdk->ds_xfer = dk->dk_xfer; diff --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c index 1ad221818b5..9cfacee759a 100644 --- a/sys/kern/subr_autoconf.c +++ b/sys/kern/subr_autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_autoconf.c,v 1.34 2003/04/19 19:08:53 krw Exp $ */ +/* $OpenBSD: subr_autoconf.c,v 1.35 2003/05/03 21:14:59 deraadt Exp $ */ /* $NetBSD: subr_autoconf.c,v 1.21 1996/04/04 06:06:18 cgd Exp $ */ /* @@ -848,6 +848,6 @@ evcnt_attach(dev, name, ev) /* ev->ev_next = NULL; */ ev->ev_dev = dev; /* ev->ev_count = 0; */ - strcpy(ev->ev_name, name); + strlcpy(ev->ev_name, name, sizeof ev->ev_name); TAILQ_INSERT_TAIL(&allevents, ev, ev_list); } diff --git a/sys/kern/subr_userconf.c b/sys/kern/subr_userconf.c index cc8868ef18d..613bfe742a2 100644 --- a/sys/kern/subr_userconf.c +++ b/sys/kern/subr_userconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_userconf.c,v 1.31 2002/07/29 23:18:57 art Exp $ */ +/* $OpenBSD: subr_userconf.c,v 1.32 2003/05/03 21:14:59 deraadt Exp $ */ /* * Copyright (c) 1996-2001 Mats O Jansson <moj@stacken.kth.se> @@ -183,7 +183,7 @@ void userconf_hist_int(val) int val; { - sprintf(userconf_histbuf," %d",val); + snprintf(userconf_histbuf, sizeof userconf_histbuf, " %d",val); if (userconf_histcur + strlen(userconf_histbuf) < userconf_histsz) { bcopy(userconf_histbuf, &userconf_history[userconf_histcur], diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 20def188a2c..b6a2aa0382a 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bridge.c,v 1.114 2003/03/31 22:59:47 millert Exp $ */ +/* $OpenBSD: if_bridge.c,v 1.115 2003/05/03 21:15:11 deraadt Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -206,7 +206,7 @@ bridgeattach(n) LIST_INIT(&sc->sc_iflist); LIST_INIT(&sc->sc_spanlist); ifp = &sc->sc_if; - sprintf(ifp->if_xname, "bridge%d", i); + snprintf(ifp->if_xname, sizeof ifp->if_xname, "bridge%d", i); ifp->if_softc = sc; ifp->if_mtu = ETHERMTU; ifp->if_ioctl = bridge_ioctl; diff --git a/sys/net/if_enc.c b/sys/net/if_enc.c index 8411f35eff5..4a7cc72a5c8 100644 --- a/sys/net/if_enc.c +++ b/sys/net/if_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_enc.c,v 1.39 2002/06/30 13:04:36 itojun Exp $ */ +/* $OpenBSD: if_enc.c,v 1.40 2003/05/03 21:15:11 deraadt Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -101,7 +101,7 @@ encattach(int nenc) for (i = 0; i < NENC; i++) { ifp = &encif[i].sc_if; - sprintf(ifp->if_xname, "enc%d", i); + snprintf(ifp->if_xname, sizeof ifp->if_xname, "enc%d", i); ifp->if_softc = &encif[i]; ifp->if_mtu = ENCMTU; ifp->if_ioctl = encioctl; diff --git a/sys/net/if_faith.c b/sys/net/if_faith.c index 45d6d7a5192..32ab43db223 100644 --- a/sys/net/if_faith.c +++ b/sys/net/if_faith.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_faith.c,v 1.13 2003/05/03 01:43:07 itojun Exp $ */ +/* $OpenBSD: if_faith.c,v 1.14 2003/05/03 21:15:11 deraadt Exp $ */ /* * Copyright (c) 1982, 1986, 1993 * The Regents of the University of California. All rights reserved. @@ -92,7 +92,7 @@ faithattach(faith) for (i = 0; i < NFAITH; i++) { ifp = &faithif[i]; bzero(ifp, sizeof(faithif[i])); - sprintf(ifp->if_xname, "faith%d", i); + snprintf(ifp->if_xname, sizeof ifp->if_xname, "faith%d", i); ifp->if_mtu = FAITHMTU; /* Change to BROADCAST experimentaly to announce its prefix. */ ifp->if_flags = /* IFF_LOOPBACK */ IFF_BROADCAST | IFF_MULTICAST; diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index d7bc71ed518..d790dcb256d 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_gif.c,v 1.27 2003/05/03 01:43:07 itojun Exp $ */ +/* $OpenBSD: if_gif.c,v 1.28 2003/05/03 21:15:11 deraadt Exp $ */ /* $KAME: if_gif.c,v 1.43 2001/02/20 08:51:07 itojun Exp $ */ /* @@ -83,7 +83,8 @@ gifattach(n) M_DEVBUF, M_WAIT); bzero(sc, ngif * sizeof(struct gif_softc)); for (i = 0; i < ngif; sc++, i++) { - sprintf(sc->gif_if.if_xname, "gif%d", i); + snprintf(sc->gif_if.if_xname, sizeof sc->gif_if.if_xname, + "gif%d", i); sc->gif_if.if_mtu = GIF_MTU; sc->gif_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST; sc->gif_if.if_ioctl = gif_ioctl; diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index 76a971badb6..6247c21ca84 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_loop.c,v 1.27 2003/05/03 01:43:07 itojun Exp $ */ +/* $OpenBSD: if_loop.c,v 1.28 2003/05/03 21:15:11 deraadt Exp $ */ /* $NetBSD: if_loop.c,v 1.15 1996/05/07 02:40:33 thorpej Exp $ */ /* @@ -191,7 +191,7 @@ loopattach(n) bzero(ifp, sizeof(struct ifnet)); if (i == 0) lo0ifp = ifp; - sprintf(ifp->if_xname, "lo%d", i); + snprintf(ifp->if_xname, sizeof ifp->if_xname, "lo%d", i); ifp->if_softc = NULL; ifp->if_mtu = LOMTU; ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST; diff --git a/sys/net/if_pflog.c b/sys/net/if_pflog.c index 7c1648ce6e5..3c93560d329 100644 --- a/sys/net/if_pflog.c +++ b/sys/net/if_pflog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pflog.c,v 1.7 2002/10/29 19:51:04 mickey Exp $ */ +/* $OpenBSD: if_pflog.c,v 1.8 2003/05/03 21:15:11 deraadt Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -93,7 +93,7 @@ pflogattach(int npflog) for (i = 0; i < NPFLOG; i++) { ifp = &pflogif[i].sc_if; - sprintf(ifp->if_xname, "pflog%d", i); + snprintf(ifp->if_xname, sizeof ifp->if_xname, "pflog%d", i); ifp->if_softc = &pflogif[i]; ifp->if_mtu = PFLOGMTU; ifp->if_ioctl = pflogioctl; diff --git a/sys/net/if_pfsync.c b/sys/net/if_pfsync.c index a14bd82f3b3..89a4f223ad9 100644 --- a/sys/net/if_pfsync.c +++ b/sys/net/if_pfsync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pfsync.c,v 1.4 2002/12/23 18:53:59 mickey Exp $ */ +/* $OpenBSD: if_pfsync.c,v 1.5 2003/05/03 21:15:11 deraadt Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff @@ -91,7 +91,7 @@ pfsyncattach(int npfsync) pfsyncif.sc_ptr = NULL; pfsyncif.sc_count = 8; ifp = &pfsyncif.sc_if; - strcpy(ifp->if_xname, "pfsync0"); + strlcpy(ifp->if_xname, "pfsync0", sizeof ifp->if_xname); ifp->if_softc = &pfsyncif; ifp->if_ioctl = pfsyncioctl; ifp->if_output = pfsyncoutput; diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c index 738535168dd..563a94bcd3a 100644 --- a/sys/net/if_ppp.c +++ b/sys/net/if_ppp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ppp.c,v 1.33 2003/02/12 14:41:07 jason Exp $ */ +/* $OpenBSD: if_ppp.c,v 1.34 2003/05/03 21:15:11 deraadt Exp $ */ /* $NetBSD: if_ppp.c,v 1.39 1997/05/17 21:11:59 christos Exp $ */ /* @@ -229,7 +229,7 @@ pppattach() for (sc = ppp_softc; i < NPPP; sc++) { sc->sc_unit = i; /* XXX */ - sprintf(sc->sc_if.if_xname, "ppp%d", i++); + snprintf(sc->sc_if.if_xname, sizeof sc->sc_if.if_xname, "ppp%d", i++); sc->sc_if.if_softc = sc; sc->sc_if.if_mtu = PPP_MTU; sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST; diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c index d9b16826e61..a43d99e47e4 100644 --- a/sys/net/if_sl.c +++ b/sys/net/if_sl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sl.c,v 1.18 2003/01/07 09:00:33 kjc Exp $ */ +/* $OpenBSD: if_sl.c,v 1.19 2003/05/03 21:15:11 deraadt Exp $ */ /* $NetBSD: if_sl.c,v 1.39.4.1 1996/06/02 16:26:31 thorpej Exp $ */ /* @@ -206,7 +206,8 @@ slattach(n) bzero(sl_softc, n * sizeof(struct sl_softc)); for (sc = sl_softc; i < nsl; sc++) { sc->sc_unit = i; /* XXX */ - sprintf(sc->sc_if.if_xname, "sl%d", i++); + snprintf(sc->sc_if.if_xname, sizeof sc->sc_if.if_xname, + "sl%d", i++); sc->sc_if.if_softc = sc; sc->sc_if.if_mtu = SLMTU; sc->sc_if.if_flags = diff --git a/sys/net/if_strip.c b/sys/net/if_strip.c index f9b31036eba..1db330d1caa 100644 --- a/sys/net/if_strip.c +++ b/sys/net/if_strip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_strip.c,v 1.23 2003/01/07 09:00:33 kjc Exp $ */ +/* $OpenBSD: if_strip.c,v 1.24 2003/05/03 21:15:11 deraadt Exp $ */ /* $NetBSD: if_strip.c,v 1.2.4.3 1996/08/03 00:58:32 jtc Exp $ */ /* from: NetBSD: if_sl.c,v 1.38 1996/02/13 22:00:23 christos Exp $ */ @@ -351,7 +351,8 @@ stripattach(n) for (sc = st_softc; i < NSTRIP; sc++) { timeout_set(&sc->sc_timo, strip_timeout, sc); sc->sc_unit = i; /* XXX */ - sprintf(sc->sc_if.if_xname, "strip%d", i++); + snprintf(sc->sc_if.if_xname, sizeof sc->sc_if.if_xname, + "strip%d", i++); sc->sc_if.if_softc = sc; sc->sc_if.if_mtu = SLMTU; sc->sc_if.if_flags = 0; diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 62046c91162..a0cfcc85016 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tun.c,v 1.46 2003/04/18 05:26:13 jason Exp $ */ +/* $OpenBSD: if_tun.c,v 1.47 2003/05/03 21:15:11 deraadt Exp $ */ /* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */ /* @@ -151,7 +151,7 @@ tunattach(n) tunctl[i].tun_flags = TUN_INITED; ifp = &tunctl[i].tun_if; - sprintf(ifp->if_xname, "tun%d", i); + snprintf(ifp->if_xname, sizeof ifp->if_xname, "tun%d", i); ifp->if_softc = &tunctl[i]; ifp->if_mtu = TUNMTU; ifp->if_ioctl = tun_ioctl; diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 22ee8975afe..5fcec917897 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan.c,v 1.36 2003/05/03 01:43:07 itojun Exp $ */ +/* $OpenBSD: if_vlan.c,v 1.37 2003/05/03 21:15:11 deraadt Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology * @@ -113,7 +113,7 @@ vlanattach(int count) LIST_INIT(&ifv_softc[i].vlan_mc_listhead); ifp = &ifv_softc[i].ifv_if; ifp->if_softc = &ifv_softc[i]; - sprintf(ifp->if_xname, "vlan%d", i); + snprintf(ifp->if_xname, sizeof ifp->if_xname, "vlan%d", i); /* NB: flags are not set here */ /* NB: mtu is not set here */ |