diff options
author | 2001-06-27 00:58:53 +0000 | |
---|---|---|
committer | 2001-06-27 00:58:53 +0000 | |
commit | f1a075da3e4bb4f84a5bb83783c6b1943dc3da49 (patch) | |
tree | f3b98ca6be26aa2b00a7770f1dceff5312265655 /lib/libc/time | |
parent | Keep track of the ACQUIRE sequence number, and pass it to the kernel (diff) | |
download | wireguard-openbsd-f1a075da3e4bb4f84a5bb83783c6b1943dc3da49.tar.xz wireguard-openbsd-f1a075da3e4bb4f84a5bb83783c6b1943dc3da49.zip |
use strlcpy vs strncpy+a[len-1]='\0'. millert@ ok.
Diffstat (limited to 'lib/libc/time')
-rw-r--r-- | lib/libc/time/localtime.c | 10 | ||||
-rw-r--r-- | lib/libc/time/zdump.c | 10 |
2 files changed, 9 insertions, 11 deletions
diff --git a/lib/libc/time/localtime.c b/lib/libc/time/localtime.c index 399d53802f0..106103ad80c 100644 --- a/lib/libc/time/localtime.c +++ b/lib/libc/time/localtime.c @@ -5,7 +5,7 @@ #if defined(LIBC_SCCS) && !defined(lint) && !defined(NOID) static char elsieid[] = "@(#)localtime.c 7.70"; -static char rcsid[] = "$OpenBSD: localtime.c,v 1.19 2000/04/16 16:24:03 d Exp $"; +static char rcsid[] = "$OpenBSD: localtime.c,v 1.20 2001/06/27 00:58:57 lebel Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -904,12 +904,10 @@ const int lastditch; if ((size_t) sp->charcnt > sizeof sp->chars) return -1; cp = sp->chars; - (void) strncpy(cp, stdname, stdlen); - cp += stdlen; - *cp++ = '\0'; + strlcpy(cp, stdname, stdlen + 1); + cp += stdlen + 1; if (dstlen != 0) { - (void) strncpy(cp, dstname, dstlen); - *(cp + dstlen) = '\0'; + strlcpy(cp, dstname, dstlen + 1); } return 0; } diff --git a/lib/libc/time/zdump.c b/lib/libc/time/zdump.c index de3bb6464ac..a4a4049b09b 100644 --- a/lib/libc/time/zdump.c +++ b/lib/libc/time/zdump.c @@ -1,6 +1,6 @@ #if defined(LIBC_SCCS) && !defined(lint) && !defined(NOID) static char elsieid[] = "@(#)zdump.c 7.29"; -static char rcsid[] = "$OpenBSD: zdump.c,v 1.8 2001/03/26 15:25:51 millert Exp $"; +static char rcsid[] = "$OpenBSD: zdump.c,v 1.9 2001/06/27 00:58:57 lebel Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -229,7 +229,7 @@ _("%s: usage is %s [ -v ] [ -c cutoff ] zonename ...\n"), t += SECSPERHOUR * HOURSPERDAY; show(argv[i], t, TRUE); tm = *localtime(&t); - (void) strncpy(buf, abbr(&tm), (sizeof buf) - 1); + strlcpy(buf, abbr(&tm), (sizeof buf)); for ( ; ; ) { if (cutoff != NULL && t >= cuttime) break; @@ -244,8 +244,8 @@ _("%s: usage is %s [ -v ] [ -c cutoff ] zonename ...\n"), strcmp(abbr(&newtm), buf) != 0) { newt = hunt(argv[i], t, newt); newtm = *localtime(&newt); - (void) strncpy(buf, abbr(&newtm), - (sizeof buf) - 1); + strlcpy(buf, abbr(&newtm), + (sizeof buf)); } t = newt; tm = newtm; @@ -285,7 +285,7 @@ time_t hit; static char loab[MAX_STRING_LENGTH]; lotm = *localtime(&lot); - (void) strncpy(loab, abbr(&lotm), (sizeof loab) - 1); + strlcpy(loab, abbr(&lotm), (sizeof loab)); while ((hit - lot) >= 2) { t = lot / 2 + hit / 2; if (t <= lot) |