Made sure the string formated by strftime() is properly

null-terminated.

Should go to RELENG_2_1 and RELENG_2_2.

Reviewed by guido@freebsd.org.
This commit is contained in:
Kazutaka YOKOTA 1997-03-07 10:54:19 +00:00
parent d36dc5e36b
commit 6d7977a7cc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=23493
2 changed files with 4 additions and 2 deletions

View File

@ -76,7 +76,8 @@ pr_attime(started, now)
(void)strcpy(fmt, __CONCAT("%l:%", "M%p"));
}
(void)strftime(buf, sizeof(buf), fmt, tp);
(void)strftime(buf, sizeof(buf) - 1, fmt, tp);
buf[sizeof(buf) - 1] = '\0';
(void)printf("%s", buf);
}

View File

@ -377,8 +377,9 @@ pr_header(nowp, nusers)
* SCCS forces the string manipulation below, as it replaces
* %, M, and % in a character string with the file name.
*/
(void)strftime(buf, sizeof(buf),
(void)strftime(buf, sizeof(buf) - 1,
__CONCAT("%l:%","M%p"), localtime(nowp));
buf[sizeof(buf) - 1] = '\0';
(void)printf("%s ", buf);
/*