summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2002-05-29 18:39:01 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2002-05-29 18:39:01 +0000
commitda4b035c00c91f83f53006859ff51cc6316c59fd (patch)
tree5b71ada85fe1e39d042db8b6a28ab5ba06a71408
parent8852a4e96620349bdbb8b1910914433eb4ae5b23 (diff)
more strlcat and strlcpy
-rw-r--r--usr.sbin/amd/amd/amd.c4
-rw-r--r--usr.sbin/amd/amd/mapc.c4
-rw-r--r--usr.sbin/config/gram.y4
-rw-r--r--usr.sbin/pwd_mkdb/pwd_mkdb.c8
-rw-r--r--usr.sbin/rbootd/bpf.c6
-rw-r--r--usr.sbin/rbootd/utils.c9
-rw-r--r--usr.sbin/rpc.lockd/procs.c12
7 files changed, 23 insertions, 24 deletions
diff --git a/usr.sbin/amd/amd/amd.c b/usr.sbin/amd/amd/amd.c
index 9c4e49d054d..52b4a39d446 100644
--- a/usr.sbin/amd/amd/amd.c
+++ b/usr.sbin/amd/amd/amd.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* from: @(#)amd.c 8.1 (Berkeley) 6/6/93
- * $Id: amd.c,v 1.5 2002/05/26 02:49:50 deraadt Exp $
+ * $Id: amd.c,v 1.6 2002/05/29 18:39:00 deraadt Exp $
*/
#ifndef lint
@@ -245,7 +245,7 @@ char *argv[];
*domdot++ = '\0';
hostdomain = domdot;
}
- strcpy(hostd, hostname);
+ strlcpy(hostd, hostname, sizeof hostd);
/*
* Trap interrupts for shutdowns.
diff --git a/usr.sbin/amd/amd/mapc.c b/usr.sbin/amd/amd/mapc.c
index becc6d1a922..aeeb4a360a6 100644
--- a/usr.sbin/amd/amd/mapc.c
+++ b/usr.sbin/amd/amd/mapc.c
@@ -38,7 +38,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)mapc.c 8.1 (Berkeley) 6/6/93";*/
-static char *rcsid = "$Id: mapc.c,v 1.2 2001/03/02 06:22:03 deraadt Exp $";
+static char *rcsid = "$Id: mapc.c,v 1.3 2002/05/29 18:39:00 deraadt Exp $";
#endif /* not lint */
/*
@@ -705,7 +705,7 @@ int recurse;
* For example:
* "src/gnu/gcc" -> "src / gnu / *" -> "src / *"
*/
- strcpy(wildname, key);
+ strlcpy(wildname, key, sizeof wildname);
while (error && (subp = strrchr(wildname, '/'))) {
strcpy(subp, "/*");
#ifdef DEBUG
diff --git a/usr.sbin/config/gram.y b/usr.sbin/config/gram.y
index f616ff61936..3427fc593b2 100644
--- a/usr.sbin/config/gram.y
+++ b/usr.sbin/config/gram.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: gram.y,v 1.12 2002/02/16 21:28:01 millert Exp $ */
+/* $OpenBSD: gram.y,v 1.13 2002/05/29 18:39:00 deraadt Exp $ */
/* $NetBSD: gram.y,v 1.14 1997/02/02 21:12:32 thorpej Exp $ */
/*
@@ -457,7 +457,7 @@ setmachine(mch, mcharch)
(void)sprintf(buf, "arch/%s/conf/files.%s",
machinearch, machinearch);
else
- strcpy(buf, _PATH_DEVNULL);
+ strlcpy(buf, _PATH_DEVNULL, sizeof buf);
if (include(buf, ENDFILE) != 0)
exit(1);
diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c
index 1b406ffafc6..7dcc77cf524 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.28 2002/05/22 09:09:32 deraadt Exp $ */
+/* $OpenBSD: pwd_mkdb.c,v 1.29 2002/05/29 18:39:00 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.28 2002/05/22 09:09:32 deraadt Exp $";
+static char *rcsid = "$OpenBSD: pwd_mkdb.c,v 1.29 2002/05/29 18:39:00 deraadt Exp $";
#endif
#endif /* not lint */
@@ -481,8 +481,8 @@ changedir(path, dir)
p = strrchr(path, '/');
strlcpy(fixed, dir, sizeof fixed);
if (p) {
- strcat(fixed, "/");
- strcat(fixed, p + 1);
+ strlcat(fixed, "/", sizeof fixed);
+ strlcat(fixed, p + 1, sizeof fixed);
}
return (fixed);
}
diff --git a/usr.sbin/rbootd/bpf.c b/usr.sbin/rbootd/bpf.c
index a0c6f7aad9a..f016ed12090 100644
--- a/usr.sbin/rbootd/bpf.c
+++ b/usr.sbin/rbootd/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.9 2002/05/29 09:45:08 deraadt Exp $ */
+/* $OpenBSD: bpf.c,v 1.10 2002/05/29 18:39:00 deraadt Exp $ */
/* $NetBSD: bpf.c,v 1.5.2.1 1995/11/14 08:45:42 thorpej Exp $ */
/*
@@ -49,7 +49,7 @@
#ifndef lint
/*static char sccsid[] = "@(#)bpf.c 8.1 (Berkeley) 6/4/93";*/
-static char rcsid[] = "$OpenBSD: bpf.c,v 1.9 2002/05/29 09:45:08 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: bpf.c,v 1.10 2002/05/29 18:39:00 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -297,7 +297,7 @@ BpfGetIntfName(errmsg)
return(NULL);
}
- (void) strcpy(device, mp->ifr_name);
+ (void) strlcpy(device, mp->ifr_name, sizeof device);
return(device);
}
diff --git a/usr.sbin/rbootd/utils.c b/usr.sbin/rbootd/utils.c
index ad8c0d14c18..327073f7e45 100644
--- a/usr.sbin/rbootd/utils.c
+++ b/usr.sbin/rbootd/utils.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utils.c,v 1.5 2002/03/14 16:44:25 mpech Exp $ */
+/* $OpenBSD: utils.c,v 1.6 2002/05/29 18:39:00 deraadt Exp $ */
/* $NetBSD: utils.c,v 1.5.2.1 1995/11/14 08:45:46 thorpej Exp $ */
/*
@@ -49,7 +49,7 @@
#ifndef lint
/*static char sccsid[] = "@(#)utils.c 8.1 (Berkeley) 6/4/93";*/
-static char rcsid[] = "$OpenBSD: utils.c,v 1.5 2002/03/14 16:44:25 mpech Exp $";
+static char rcsid[] = "$OpenBSD: utils.c,v 1.6 2002/05/29 18:39:00 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -338,12 +338,11 @@ NewStr(str)
{
char *stmp;
- if ((stmp = (char *)malloc((unsigned) (strlen(str)+1))) == NULL) {
+ stmp = strdup(str);
+ if (stmp == NULL) {
syslog(LOG_ERR, "NewStr: out of memory (%s)", str);
return(NULL);
}
-
- (void) strcpy(stmp, str);
return(stmp);
}
diff --git a/usr.sbin/rpc.lockd/procs.c b/usr.sbin/rpc.lockd/procs.c
index b0a873d57f4..2edca80d499 100644
--- a/usr.sbin/rpc.lockd/procs.c
+++ b/usr.sbin/rpc.lockd/procs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: procs.c,v 1.9 2000/06/29 00:30:39 millert Exp $ */
+/* $OpenBSD: procs.c,v 1.10 2002/05/29 18:39:00 deraadt Exp $ */
/*
* Copyright (c) 1995
@@ -63,11 +63,11 @@ log_from_addr(fun_name, req)
addr = svc_getcaller(req->rq_xprt);
host = gethostbyaddr((char *) &(addr->sin_addr), addr->sin_len, AF_INET);
- if (host) {
- strncpy(hostname_buf, host->h_name, sizeof(hostname_buf) - 1);
- hostname_buf[sizeof(hostname_buf) - 1] = '\0';
- } else
- strcpy(hostname_buf, inet_ntoa(addr->sin_addr));
+ if (host)
+ strlcpy(hostname_buf, host->h_name, sizeof(hostname_buf));
+ else
+ strlcpy(hostname_buf, inet_ntoa(addr->sin_addr),
+ sizeof hostname_buf);
syslog(LOG_DEBUG, "%s from %s", fun_name, hostname_buf);
}