summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2001-05-11 18:35:22 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2001-05-11 18:35:22 +0000
commitfa8fbd556da5ab50dba3e41a276a115364fbd5cc (patch)
tree84d857f4528a38a43a491308df6e1b43fd5ba1fc
parent34b763bdeb8fd393fd97e1791d60b1143d91e6f0 (diff)
use strlcpy instead of strncpy+a[len-1]='\0'
-rw-r--r--sbin/mountd/mountd.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/sbin/mountd/mountd.c b/sbin/mountd/mountd.c
index bfc1d8a03f7..11a53c7dd08 100644
--- a/sbin/mountd/mountd.c
+++ b/sbin/mountd/mountd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mountd.c,v 1.35 2001/01/17 19:27:11 deraadt Exp $ */
+/* $OpenBSD: mountd.c,v 1.36 2001/05/11 18:35:21 mickey Exp $ */
/* $NetBSD: mountd.c,v 1.31 1996/02/18 11:57:53 fvdl Exp $ */
/*
@@ -259,11 +259,7 @@ main(argc, argv)
exphead = NULL;
mlhead = NULL;
- if (argc == 1)
- strncpy(exname, *argv, sizeof(exname)-1);
- else
- strncpy(exname, _PATH_EXPORTS, sizeof exname-1);
- exname[sizeof(exname)-1] = '\0';
+ strlcpy(exname, argc == 1? *argv : _PATH_EXPORTS, sizeof(exname));
openlog("mountd", LOG_PID, LOG_DAEMON);
if (debug)
@@ -1941,10 +1937,8 @@ get_mountlist()
if (host == NULL || dirp == NULL)
continue;
mlp = (struct mountlist *)malloc(sizeof (*mlp));
- strncpy(mlp->ml_host, host, RPCMNT_NAMELEN);
- mlp->ml_host[RPCMNT_NAMELEN] = '\0';
- strncpy(mlp->ml_dirp, dirp, RPCMNT_PATHLEN);
- mlp->ml_dirp[RPCMNT_PATHLEN] = '\0';
+ strlcpy(mlp->ml_host, host, sizeof(mlp->ml_host));
+ strlcpy(mlp->ml_dirp, dirp, sizeof(mlp->ml_dirp));
mlp->ml_next = NULL;
*mlpp = mlp;
mlpp = &mlp->ml_next;
@@ -2006,10 +2000,8 @@ add_mlist(hostp, dirp)
mlp = mlp->ml_next;
}
mlp = (struct mountlist *)malloc(sizeof (*mlp));
- strncpy(mlp->ml_host, hostp, RPCMNT_NAMELEN);
- mlp->ml_host[RPCMNT_NAMELEN] = '\0';
- strncpy(mlp->ml_dirp, dirp, RPCMNT_PATHLEN);
- mlp->ml_dirp[RPCMNT_PATHLEN] = '\0';
+ strlcpy(mlp->ml_host, hostp, sizeof(mlp->ml_host));
+ strlcpy(mlp->ml_dirp, dirp, sizeof(mlp->ml_dirp, dirp));
mlp->ml_next = NULL;
*mlpp = mlp;
if ((mlfile = fopen(_PATH_RMOUNTLIST, "a")) == NULL) {