Fake usec timestamp for untrusted kernel log messages

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg 2022-06-04 18:52:03 +02:00
parent 4bbed71c29
commit 1e9f164198

View File

@ -1366,12 +1366,17 @@ void printsys(char *msg)
*/
if (KeepKernTime || !sys_seqno_init) {
now = boot_time + ustime / 1000000;
buffer.timestamp.usec = ustime % 1000000;
localtime_r(&now, &buffer.timestamp.tm);
} else
} else {
struct timeval tv;
now = time(NULL);
if (!gettimeofday(&tv, NULL))
ustime = tv.tv_usec * 1000000;
}
localtime_r(&now, &buffer.timestamp.tm);
buffer.timestamp.usec = ustime % 1000000;
/* skip flags for now */
q = strchr(p, ';');