diff options
author | 2002-05-22 09:09:32 +0000 | |
---|---|---|
committer | 2002-05-22 09:09:32 +0000 | |
commit | 2261d3e17ed89f657e62c341ce13baef19457ca1 (patch) | |
tree | 164075cf3e4c218c5213d4064c264a1401da6596 /usr.sbin | |
parent | Small fix: - Start new sentence on a new line. (diff) | |
download | wireguard-openbsd-2261d3e17ed89f657e62c341ce13baef19457ca1.tar.xz wireguard-openbsd-2261d3e17ed89f657e62c341ce13baef19457ca1.zip |
more strcpy/sprintf death; mpech ok
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/inetd/inetd.c | 8 | ||||
-rw-r--r-- | usr.sbin/pwd_mkdb/pwd_mkdb.c | 6 | ||||
-rw-r--r-- | usr.sbin/quotaon/quotaon.c | 4 | ||||
-rw-r--r-- | usr.sbin/route6d/route6d.c | 9 | ||||
-rw-r--r-- | usr.sbin/rtsold/probe.c | 4 | ||||
-rw-r--r-- | usr.sbin/sa/pdb.c | 8 | ||||
-rw-r--r-- | usr.sbin/sliplogin/sliplogin.c | 4 | ||||
-rw-r--r-- | usr.sbin/ypserv/revnetgroup/parse_netgroup.c | 11 |
8 files changed, 28 insertions, 26 deletions
diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c index 957d65e1137..83942678bca 100644 --- a/usr.sbin/inetd/inetd.c +++ b/usr.sbin/inetd/inetd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inetd.c,v 1.89 2002/03/14 16:44:25 mpech Exp $ */ +/* $OpenBSD: inetd.c,v 1.90 2002/05/22 09:09:32 deraadt Exp $ */ /* $NetBSD: inetd.c,v 1.11 1996/02/22 11:14:41 mycroft Exp $ */ /* * Copyright (c) 1983,1991 The Regents of the University of California. @@ -41,7 +41,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)inetd.c 5.30 (Berkeley) 6/3/91";*/ -static char rcsid[] = "$OpenBSD: inetd.c,v 1.89 2002/03/14 16:44:25 mpech Exp $"; +static char rcsid[] = "$OpenBSD: inetd.c,v 1.90 2002/05/22 09:09:32 deraadt Exp $"; #endif /* not lint */ /* @@ -1998,7 +1998,7 @@ daytime_stream(s, sep) /* Return human-readable time of day */ clock = time(NULL); - (void) sprintf(buffer, "%.24s\r\n", ctime(&clock)); + (void) snprintf(buffer, sizeof buffer, "%.24s\r\n", ctime(&clock)); (void) write(s, buffer, strlen(buffer)); } @@ -2021,7 +2021,7 @@ daytime_dg(s, sep) /* Return human-readable time of day */ return; if (dg_badinput((struct sockaddr *)&ss)) return; - (void) sprintf(buffer, "%.24s\r\n", ctime(&clock)); + (void) snprintf(buffer, sizeof buffer, "%.24s\r\n", ctime(&clock)); (void) sendto(s, buffer, strlen(buffer), 0, (struct sockaddr *)&ss, size); } diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c index 1de1d15d0de..1b406ffafc6 100644 --- a/usr.sbin/pwd_mkdb/pwd_mkdb.c +++ b/usr.sbin/pwd_mkdb/pwd_mkdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pwd_mkdb.c,v 1.27 2002/02/16 21:28:08 millert Exp $ */ +/* $OpenBSD: pwd_mkdb.c,v 1.28 2002/05/22 09:09:32 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -45,7 +45,7 @@ static char copyright[] = #if 0 static char sccsid[] = "from: @(#)pwd_mkdb.c 8.5 (Berkeley) 4/20/94"; #else -static char *rcsid = "$OpenBSD: pwd_mkdb.c,v 1.27 2002/02/16 21:28:08 millert Exp $"; +static char *rcsid = "$OpenBSD: pwd_mkdb.c,v 1.28 2002/05/22 09:09:32 deraadt Exp $"; #endif #endif /* not lint */ @@ -479,7 +479,7 @@ changedir(path, dir) return (path); p = strrchr(path, '/'); - strcpy(fixed, dir); + strlcpy(fixed, dir, sizeof fixed); if (p) { strcat(fixed, "/"); strcat(fixed, p + 1); diff --git a/usr.sbin/quotaon/quotaon.c b/usr.sbin/quotaon/quotaon.c index 1b95735b6f9..f606df31eca 100644 --- a/usr.sbin/quotaon/quotaon.c +++ b/usr.sbin/quotaon/quotaon.c @@ -42,7 +42,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)quotaon.c 8.1 (Berkeley) 6/6/93";*/ -static char *rcsid = "$Id: quotaon.c,v 1.12 2002/03/14 16:44:25 mpech Exp $"; +static char *rcsid = "$Id: quotaon.c,v 1.13 2002/05/22 09:09:32 deraadt Exp $"; #endif /* not lint */ /* @@ -219,7 +219,7 @@ hasquota(fs, type, qfnamep, force) sprintf(grpname, "%s%s", qfextension[GRPQUOTA], qfname); initname = 1; } - strcpy(buf, fs->fs_mntops); + strlcpy(buf, fs->fs_mntops, sizeof buf); for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) { if (cp = strchr(opt, '=')) *cp++ = '\0'; diff --git a/usr.sbin/route6d/route6d.c b/usr.sbin/route6d/route6d.c index e7b12a38561..84e0d7fd983 100644 --- a/usr.sbin/route6d/route6d.c +++ b/usr.sbin/route6d/route6d.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route6d.c,v 1.26 2002/02/25 02:33:06 itojun Exp $ */ +/* $OpenBSD: route6d.c,v 1.27 2002/05/22 09:09:32 deraadt Exp $ */ /* $KAME: route6d.c,v 1.81 2002/02/25 02:27:22 itojun Exp $ */ /* @@ -31,7 +31,7 @@ */ #if 0 -static char _rcsid[] = "$OpenBSD: route6d.c,v 1.26 2002/02/25 02:33:06 itojun Exp $"; +static char _rcsid[] = "$OpenBSD: route6d.c,v 1.27 2002/05/22 09:09:32 deraadt Exp $"; #endif #include <stdio.h> @@ -3256,14 +3256,15 @@ char * allocopy(p) char *p; { - char *q = (char *)malloc(strlen(p) + 1); + int len = strlen(p) + 1; + char *q = (char *)malloc(len); if (!q) { fatal("malloc"); /*NOTREACHED*/ } - strcpy(q, p); + strlcpy(q, p, len); return q; } diff --git a/usr.sbin/rtsold/probe.c b/usr.sbin/rtsold/probe.c index ea1e175d8cc..2b79441cd25 100644 --- a/usr.sbin/rtsold/probe.c +++ b/usr.sbin/rtsold/probe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: probe.c,v 1.4 2002/02/16 21:28:09 millert Exp $ */ +/* $OpenBSD: probe.c,v 1.5 2002/05/22 09:09:32 deraadt Exp $ */ /* $KAME: probe.c,v 1.10 2000/08/13 06:14:59 itojun Exp $ */ /* @@ -112,7 +112,7 @@ defrouter_probe(int ifindex) return; } bzero(&dr, sizeof(dr)); - strcpy(dr.ifname, "lo0"); /* dummy interface */ + strlcpy(dr.ifname, "lo0", sizeof dr.ifname); /* dummy interface */ if (ioctl(s, SIOCGDRLST_IN6, (caddr_t)&dr) < 0) { warnmsg(LOG_ERR, __FUNCTION__, "ioctl(SIOCGDRLST_IN6): %s", strerror(errno)); diff --git a/usr.sbin/sa/pdb.c b/usr.sbin/sa/pdb.c index 4157e764f88..7989bf12d5f 100644 --- a/usr.sbin/sa/pdb.c +++ b/usr.sbin/sa/pdb.c @@ -29,7 +29,7 @@ */ #ifndef LINT -static char rcsid[] = "$Id: pdb.c,v 1.3 2002/02/16 21:28:09 millert Exp $"; +static char rcsid[] = "$Id: pdb.c,v 1.4 2002/05/22 09:09:32 deraadt Exp $"; #endif #include <sys/types.h> @@ -213,11 +213,11 @@ pacct_print() int rv; memset(&ci_total, 0, sizeof(ci_total)); - strcpy(ci_total.ci_comm, ""); + strlcpy(ci_total.ci_comm, "", sizeof ci_total.ci_comm); memset(&ci_other, 0, sizeof(ci_other)); - strcpy(ci_other.ci_comm, "***other"); + strlcpy(ci_other.ci_comm, "***other", sizeof ci_other.ci_comm); memset(&ci_junk, 0, sizeof(ci_junk)); - strcpy(ci_junk.ci_comm, "**junk**"); + strlcpy(ci_junk.ci_comm, "**junk**", sizeof ci_junk.ci_comm); /* * Retrieve them into new DB, sorted by appropriate key. diff --git a/usr.sbin/sliplogin/sliplogin.c b/usr.sbin/sliplogin/sliplogin.c index 85db9736e71..63a1e966f11 100644 --- a/usr.sbin/sliplogin/sliplogin.c +++ b/usr.sbin/sliplogin/sliplogin.c @@ -39,7 +39,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)sliplogin.c 5.6 (Berkeley) 3/2/91";*/ -static char rcsid[] = "$Id: sliplogin.c,v 1.20 2002/05/16 10:26:27 deraadt Exp $"; +static char rcsid[] = "$Id: sliplogin.c,v 1.21 2002/05/22 09:09:32 deraadt Exp $"; #endif /* not lint */ /* @@ -171,7 +171,7 @@ sigstr(s) return(sys_signame[s]); else { static char buf[32]; - (void)sprintf(buf, "sig %d", s); + (void)snprintf(buf, sizeof buf, "sig %d", s); return(buf); } } diff --git a/usr.sbin/ypserv/revnetgroup/parse_netgroup.c b/usr.sbin/ypserv/revnetgroup/parse_netgroup.c index 2a4f62eac61..b13fe325226 100644 --- a/usr.sbin/ypserv/revnetgroup/parse_netgroup.c +++ b/usr.sbin/ypserv/revnetgroup/parse_netgroup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse_netgroup.c,v 1.3 2002/03/14 16:44:25 mpech Exp $ */ +/* $OpenBSD: parse_netgroup.c,v 1.4 2002/05/22 09:09:32 deraadt Exp $ */ /* * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -51,7 +51,7 @@ #include "hash.h" #ifndef lint -static const char rcsid[] = "$OpenBSD: parse_netgroup.c,v 1.3 2002/03/14 16:44:25 mpech Exp $"; +static const char rcsid[] = "$OpenBSD: parse_netgroup.c,v 1.4 2002/05/22 09:09:32 deraadt Exp $"; #endif /* @@ -113,9 +113,10 @@ __setnetgrent(group) if (parse_netgrp(group)) __endnetgrent(); else { - grouphead.grname = (char *) - malloc(strlen(group) + 1); - strcpy(grouphead.grname, group); + int len = strlen(group) + 1; + + grouphead.grname = malloc(len); + strlcpy(grouphead.grname, group, len); } } nextgrp = grouphead.gr; |