summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2015-03-04 18:50:30 +0100
committerKarel Zak <kzak@redhat.com>2015-03-12 10:15:05 +0100
commit9efc3268cef117afdfc5b7cab03e4f91b384c3a3 (patch)
tree3f3528b211a12b5d99603fd4cf839ce5d1d64283
parentef70ccd914c51babf61685d0ea17d0cb7ce58c1c (diff)
downloadutil-linux-9efc3268cef117afdfc5b7cab03e4f91b384c3a3.tar.gz
logger: fix invalid timestamp in rfc5425 format
The timestamp is written as 2015-03-04T15:02:02.566782+0100 unfortunately, this is not an RFC3339 timestamp as demanded by rfc5424. The colon in the time offset field is missing. The correct timestamp is 2015-03-04T15:02:02.566782+01:00 (Note "+0100" vs. "+01:00")
-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 db6fd448a..7abfcf122 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -359,8 +359,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"));