Use ctime_r to build the timestamp for syslog, so that we don't

clobber a ctime buffer which is passed in.

PR:		34022
Submitted by:	Hartmut Brandt <brandt@fokus.gmd.de>
MFC after:	2 weeks
This commit is contained in:
David Malone 2002-01-25 21:49:34 +00:00
parent d2979f90e7
commit ab09ef008f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=89805

View file

@ -143,7 +143,7 @@ vsyslog(pri, fmt, ap)
register char ch, *p;
time_t now;
int fd, saved_errno;
char *stdp, tbuf[2048], fmt_cpy[1024];
char *stdp, tbuf[2048], fmt_cpy[1024], timbuf[26];
FILE *fp, *fmt_fp;
struct bufcookie tbuf_cookie;
struct bufcookie fmt_cookie;
@ -176,7 +176,7 @@ vsyslog(pri, fmt, ap)
/* Build the message. */
(void)time(&now);
(void)fprintf(fp, "<%d>", pri);
(void)fprintf(fp, "%.15s ", ctime(&now) + 4);
(void)fprintf(fp, "%.15s ", ctime_r(&now, timbuf) + 4);
if (LogStat & LOG_PERROR) {
/* Transfer to string buffer */
(void)fflush(fp);