]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output: fix timestamp missing usecs
authorVictor Julien <vjulien@oisf.net>
Fri, 18 Feb 2022 09:19:04 +0000 (10:19 +0100)
committerVictor Julien <vjulien@oisf.net>
Fri, 18 Feb 2022 19:29:57 +0000 (20:29 +0100)
On ARM 32bit with Musl `tv_usecs` is defined as `int64_t` which lead to
CreateIsoTimeString() printing all zeros on the usecs. Work around this
by first assigning to a `int64_t` and then updating the expected format
string to accept `int64_t`.

Bug: #5094.

src/util-time.c

index 4509625bc2e37283d3c4d84651bb266ccc5fa785..8da993739dcbeb20528a37b7173bb3a0f10701ae 100644 (file)
@@ -222,8 +222,9 @@ void CreateIsoTimeString (const struct timeval *ts, char *str, size_t size)
         WinStrftime(ts, t, str, size);
 #else
         char time_fmt[64] = { 0 };
-        strftime(time_fmt, sizeof(time_fmt), "%Y-%m-%dT%H:%M:%S.%%06u%z", t);
-        snprintf(str, size, time_fmt, ts->tv_usec);
+        int64_t usec = ts->tv_usec;
+        strftime(time_fmt, sizeof(time_fmt), "%Y-%m-%dT%H:%M:%S.%%06" PRIi64 "%z", t);
+        snprintf(str, size, time_fmt, usec);
 #endif
     } else {
         snprintf(str, size, "ts-error");