From d7c881e89515d69de269ede22d2207dbbc6aa672 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sun, 20 Aug 2006 06:32:40 +0000 Subject: [PATCH] Prefer strlcpy to strncpy. In one case, this saves us from re-zeroing data that's alreday 0. In another, it saves us from zeroing data that will be overwritten again. --- bin/df/df.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/df/df.c b/bin/df/df.c index 008e15c0c55..850c02f6826 100644 --- a/bin/df/df.c +++ b/bin/df/df.c @@ -113,7 +113,7 @@ main(int argc, char *argv[]) memset(&totalbuf, 0, sizeof(totalbuf)); totalbuf.f_bsize = DEV_BSIZE; - strncpy(totalbuf.f_mntfromname, "total", MNAMELEN); + strlcpy(totalbuf.f_mntfromname, "total", MNAMELEN); vfslist = NULL; while ((ch = getopt(argc, argv, "abcgHhiklmnPt:")) != -1) switch (ch) { @@ -552,7 +552,7 @@ makenetvfslist(void) *str = 'n'; *(str + 1) = 'o'; for (i = 0, strptr = str + 2; i < cnt; i++, strptr++) { - strncpy(strptr, listptr[i], 32); + strlcpy(strptr, listptr[i], 32); strptr += strlen(listptr[i]); *strptr = ','; free(listptr[i]);