mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-18 14:23:55 +00:00
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:
parent
d2979f90e7
commit
ab09ef008f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=89805
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue