From 4ab8bc7b406a52a832c53071fffda18c6819030b Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Wed, 5 May 2021 03:03:01 +0200 Subject: [PATCH] Fix #31: invalid time for kernel log messages on 32-bit machines Signed-off-by: Joachim Wiberg --- src/syslogd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/syslogd.c b/src/syslogd.c index c6ab6da..c82dbb7 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -1099,6 +1099,7 @@ void printsys(char *msg) { struct buf_msg buffer; char line[MAXLINE + 1]; + uint64_t ustime = 0; uint64_t seqno = 0; char *lp, *p, *q; int c; @@ -1137,9 +1138,9 @@ void printsys(char *msg) /* timestamp */ while (isdigit(*p)) - buffer.timestamp.usec = 10 * buffer.timestamp.usec + (*p++ - '0'); - now += buffer.timestamp.usec / 1000000; - buffer.timestamp.usec = buffer.timestamp.usec % 1000000; + ustime = 10 * ustime + (*p++ - '0'); + now += ustime / 1000000; + buffer.timestamp.usec = ustime % 1000000; localtime_r(&now, &buffer.timestamp.tm); /* skip flags for now */