]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
log: make sure that date is correctly formatted 1334/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 29 Nov 2016 06:50:29 +0000 (07:50 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 29 Nov 2016 06:52:30 +0000 (07:52 +0100)
- single digit months, days, hours, minutes, and seconds should always be
  preceded by a 0.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/log.c

index 549a1602b9988ae89871bfd119736dd357bd1b42..17e81d262f532b68cbc4cdcf85e509535b7c8427 100644 (file)
@@ -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;