summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2015-03-05 11:52:00 +0100
committerKarel Zak2015-03-05 11:52:00 +0100
commitec27f470483a7a617bd7227807d4faca16e2e652 (patch)
tree9ad1ab6bab30fab0b50797eca7c5b8d4d19ad555
parenttailf: use size_t and fwrite() (diff)
parentlogger: fix invalid timestamp in rfc5425 format (diff)
downloadkernel-qcow2-util-linux-ec27f470483a7a617bd7227807d4faca16e2e652.tar.gz
kernel-qcow2-util-linux-ec27f470483a7a617bd7227807d4faca16e2e652.tar.xz
kernel-qcow2-util-linux-ec27f470483a7a617bd7227807d4faca16e2e652.zip
Merge branch 'logger-fix-rfc5424-timestamp' of https://github.com/rgerhards/util-linux
* 'logger-fix-rfc5424-timestamp' of https://github.com/rgerhards/util-linux: logger: fix invalid timestamp in rfc5425 format
-rw-r--r--misc-utils/logger.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index 0604e6109..1e7e2dc10 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -360,8 +360,12 @@ static void syslog_rfc5424(const struct logger_ctl *ctl, const char *msg)
if ((tm = localtime(&tv.tv_sec)) != NULL) {
char fmt[64];
- strftime(fmt, sizeof(fmt), " %Y-%m-%dT%H:%M:%S.%%06u%z",
- tm);
+ const size_t i = strftime(fmt, sizeof(fmt),
+ " %Y-%m-%dT%H:%M:%S.%%06u%z ", tm);
+ /* patch TZ info to comply with RFC3339 (we left SP at end) */
+ fmt[i-1] = fmt[i-2];
+ fmt[i-2] = fmt[i-3];
+ fmt[i-3] = ':';
snprintf(time, sizeof(time), fmt, tv.tv_usec);
} else
err(EXIT_FAILURE, _("localtime() failed"));