diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2003-05-17 20:07:54 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2003-05-17 20:07:54 +0000 |
commit | ca15cb863aeefddf88ecacd7a1e3a275829f11eb (patch) | |
tree | c53c85d947be7977a497ea9a89e1424fa88825bf /usr.sbin/syslogd | |
parent | 02f3b3510d0b0af1b034d8390f9ca5d05444595f (diff) | |
download | FreeBSD-src-ca15cb863aeefddf88ecacd7a1e3a275829f11eb.zip FreeBSD-src-ca15cb863aeefddf88ecacd7a1e3a275829f11eb.tar.gz |
Avoid a corrupt timestamp on the console
PR: 51587
Submitted by: Dmitry Sivachenko <mitya@cavia.pp.ru>
Approved by: re (rwatson)
MFC after: 3 days
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r-- | usr.sbin/syslogd/syslogd.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 5d2f21b..b74007d 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -873,6 +873,8 @@ logmsg(int pri, const char *msg, const char *from, int flags) f->f_file = open(ctty, O_WRONLY, 0); if (f->f_file >= 0) { + (void)strlcpy(f->f_lasttime, timestamp, + sizeof(f->f_lasttime)); fprintlog(f, flags, msg); (void)close(f->f_file); } @@ -911,7 +913,8 @@ logmsg(int pri, const char *msg, const char *from, int flags) (flags & MARK) == 0 && msglen == f->f_prevlen && !strcmp(msg, f->f_prevline) && !strcasecmp(from, f->f_prevhost)) { - (void)strlcpy(f->f_lasttime, timestamp, 16); + (void)strlcpy(f->f_lasttime, timestamp, + sizeof(f->f_lasttime)); f->f_prevcount++; dprintf("msg repeated %d times, %ld sec of %d\n", f->f_prevcount, (long)(now - f->f_time), @@ -932,7 +935,8 @@ logmsg(int pri, const char *msg, const char *from, int flags) fprintlog(f, 0, (char *)NULL); f->f_repeatcount = 0; f->f_prevpri = pri; - (void)strlcpy(f->f_lasttime, timestamp, 16); + (void)strlcpy(f->f_lasttime, timestamp, + sizeof(f->f_lasttime)); (void)strlcpy(f->f_prevhost, from, sizeof(f->f_prevhost)); if (msglen < MAXSVLINE) { |