summaryrefslogtreecommitdiffstats
path: root/usr.bin/w
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>2003-09-07 16:31:32 +0000
committercharnier <charnier@FreeBSD.org>2003-09-07 16:31:32 +0000
commiteed88f74618b84f94a2330658ff5f75c64333cb7 (patch)
tree278620a6ef2aad6c02202df50d7660971d5f0554 /usr.bin/w
parent1af7e008376bae5d06a18f05a57d5b90d8c32511 (diff)
downloadFreeBSD-src-eed88f74618b84f94a2330658ff5f75c64333cb7.zip
FreeBSD-src-eed88f74618b84f94a2330658ff5f75c64333cb7.tar.gz
Do not print the result of strftime() in case of failure, the content is
indeterminate in such a case. The correct value for 2nd argument is sizeof(buf). Do not NUL-terminate the result string, strftime() will do it for us.
Diffstat (limited to 'usr.bin/w')
-rw-r--r--usr.bin/w/w.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c
index 8bf63d1..ebf2a87 100644
--- a/usr.bin/w/w.c
+++ b/usr.bin/w/w.c
@@ -432,11 +432,9 @@ pr_header(time_t *nowp, int nusers)
/*
* Print time of day.
*/
- (void)strftime(buf, sizeof(buf) - 1,
- use_ampm ? "%l:%M%p" : "%k:%M", localtime(nowp));
- buf[sizeof(buf) - 1] = '\0';
- (void)printf("%s ", buf);
-
+ if (strftime(buf, sizeof(buf),
+ use_ampm ? "%l:%M%p" : "%k:%M", localtime(nowp)) != 0)
+ (void)printf("%s ", buf);
/*
* Print how long system has been up.
* (Found by looking getting "boottime" from the kernel)
OpenPOWER on IntegriCloud