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.
This commit is contained in:
parent
3f22597838
commit
69fe77ce99
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=119854
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user