]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Correct formatting of trace log microseconds
authorGreg Hudson <ghudson@mit.edu>
Fri, 3 Apr 2020 05:04:06 +0000 (01:04 -0400)
committerGreg Hudson <ghudson@mit.edu>
Fri, 10 Apr 2020 17:15:44 +0000 (13:15 -0400)
Always use six digits with leading 0s to format the microseconds in
trace log timestamps; otherwise a small value appears as too large of
a fraction of a second.

(cherry picked from commit 734bf341da54e09add9160e65ea7308072b97f13)

ticket: 8894
version_fixed: 1.17.2

src/lib/krb5/os/trace.c

index 4fff8f38c20bcf5cf24e1930aff5fb453417f296..d5c71ec2e39128d91ee4590aa3a1dbe9339fcb64 100644 (file)
@@ -411,8 +411,8 @@ krb5int_trace(krb5_context context, const char *fmt, ...)
         goto cleanup;
     if (krb5_crypto_us_timeofday(&sec, &usec) != 0)
         goto cleanup;
-    if (asprintf(&msg, "[%d] %u.%d: %s\n", (int) getpid(), (unsigned int) sec,
-                 (int) usec, str) < 0)
+    if (asprintf(&msg, "[%d] %u.%06d: %s\n", (int)getpid(),
+                 (unsigned int)sec, (int)usec, str) < 0)
         goto cleanup;
     info.message = msg;
     context->trace_callback(context, &info, context->trace_callback_data);