From 9d7468fdd3aa9b5e4a9da729a4dd6d78e58fed91 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Tue, 29 Nov 2016 07:50:29 +0100 Subject: [PATCH] log: make sure that date is correctly formatted - single digit months, days, hours, minutes, and seconds should always be preceded by a 0. Signed-off-by: Christian Brauner --- src/lxc/log.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lxc/log.c b/src/lxc/log.c index 549a1602b..17e81d262 100644 --- a/src/lxc/log.c +++ b/src/lxc/log.c @@ -224,8 +224,9 @@ int lxc_unix_epoch_to_utc(char *buf, size_t bufsize, const struct timespec *time /* Create final timestamp for the log and shorten nanoseconds to 3 * digit precision. */ - ret = snprintf(buf, bufsize, "%" PRId64 "%" PRId64 "%" PRId64 "%" PRId64 - "%" PRId64 "%" PRId64 ".%.3s", + ret = snprintf(buf, bufsize, + "%" PRId64 "%02" PRId64 "%02" PRId64 "%02" PRId64 + "%02" PRId64 "%02" PRId64 ".%.3s", year, month, day, hours, minutes, seconds, nanosec); if (ret < 0 || (size_t)ret >= bufsize) return -1;