diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-08-27 03:36:58 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-08-27 03:36:58 +0000 |
commit | c5da8345d2d8f4778e00bbb71d2722b064cd4877 (patch) | |
tree | 3b22c5b9d965d9fd50a72d7b8ff70701df439925 | |
parent | 3e8cde4631e0295486eb6b32fd2bacc268f5c3b3 (diff) |
use strncpy correctly
-rw-r--r-- | lib/libc/time/zdump.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/libc/time/zdump.c b/lib/libc/time/zdump.c index 0f034b74d98..e0f76d13fac 100644 --- a/lib/libc/time/zdump.c +++ b/lib/libc/time/zdump.c @@ -1,5 +1,5 @@ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: zdump.c,v 1.2 1996/08/19 08:34:55 tholo Exp $"; +static char rcsid[] = "$OpenBSD: zdump.c,v 1.3 1996/08/27 03:36:57 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ /* @@ -189,7 +189,8 @@ char * argv[]; t += SECSPERHOUR * HOURSPERDAY; show(argv[i], t, TRUE); tm = *localtime(&t); - (void) strncpy(buf, abbr(&tm), (sizeof buf) - 1); + (void) strncpy(buf, abbr(&tm), sizeof(buf) - 1); + buf[sizeof(buf) - 1] = '\0'; for ( ; ; ) { if (cutoff != NULL && t >= cuttime) break; @@ -205,7 +206,8 @@ char * argv[]; newt = hunt(argv[i], t, newt); newtm = *localtime(&newt); (void) strncpy(buf, abbr(&newtm), - (sizeof buf) - 1); + sizeof(buf) - 1); + buf[sizeof(buf) - 1] = '\0'; } t = newt; tm = newtm; @@ -246,7 +248,8 @@ time_t hit; static char loab[MAX_STRING_LENGTH]; lotm = *localtime(&lot); - (void) strncpy(loab, abbr(&lotm), (sizeof loab) - 1); + (void) strncpy(loab, abbr(&lotm), sizeof(loab) - 1); + loab[sizeof(loab) - 1] = '\0'; while ((hit - lot) >= 2) { t = lot / 2 + hit / 2; if (t <= lot) |