From 2b4ad7a6eda15544ea3b5b87c7258ceda7a7053d Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Fri, 22 Dec 2000 22:47:05 +0000 Subject: strlcpy is great --- sbin/sysctl/sysctl.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'sbin/sysctl/sysctl.c') diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 43571198475..2cf4219711f 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.c,v 1.54 2000/11/21 06:18:27 millert Exp $ */ +/* $OpenBSD: sysctl.c,v 1.55 2000/12/22 22:47:04 deraadt Exp $ */ /* $NetBSD: sysctl.c,v 1.9 1995/09/30 07:12:50 thorpej Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)sysctl.c 8.5 (Berkeley) 5/9/95"; #else -static char *rcsid = "$OpenBSD: sysctl.c,v 1.54 2000/11/21 06:18:27 millert Exp $"; +static char *rcsid = "$OpenBSD: sysctl.c,v 1.55 2000/12/22 22:47:04 deraadt Exp $"; #endif #endif /* not lint */ @@ -247,8 +247,7 @@ listall(prefix, lp) if (lp->list == NULL) return; - (void)strncpy(name, prefix, BUFSIZ-1); - name[BUFSIZ-1] = '\0'; + (void)strlcpy(name, prefix, BUFSIZ); cp = &name[strlen(name)]; *cp++ = '.'; for (lvl2 = 0; lvl2 < lp->size; lvl2++) { @@ -278,8 +277,7 @@ parse(string, flags) int mib[CTL_MAXNAME]; char *cp, *bufp, buf[BUFSIZ]; - (void)strncpy(buf, string, sizeof(buf) - 1); - buf[sizeof(buf) - 1] = '\0'; + (void)strlcpy(buf, string, sizeof(buf)); bufp = buf; if ((cp = strchr(string, '=')) != NULL) { if (!wflag) -- cgit v1.2.3