]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2887. [bug] Report the keytag times in UTC in the .key file,
authorMark Andrews <marka@isc.org>
Wed, 12 May 2010 23:49:40 +0000 (23:49 +0000)
committerMark Andrews <marka@isc.org>
Wed, 12 May 2010 23:49:40 +0000 (23:49 +0000)
                        local time is presented as a comment within the
                        comment.  [RT #21223]

2886.   [bug]           ctime() is not thread safe. [RT #21223]

CHANGES
lib/dns/dst_api.c

diff --git a/CHANGES b/CHANGES
index f46298e90c4be96484749450a7da14744adef5c2..fd49e6fa3cef45cacd4dd6bcbee5b42e725aeac2 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+2887.  [bug]           Report the keytag times in UTC in the .key file,
+                       local time is presented as a comment within the
+                       comment.  [RT #21223]
+
+2886.  [bug]           ctime() is not thread safe. [RT #21223]
+
 2885.  [bug]           Improve -fno-strict-aliasing support probing in
                        configure. [RT #21080]
 
index 468aac1138cea624e71cbc8fb6e9311581393460..8be1286b1f6e9b0024098d25f4c0d2a3b2390d61 100644 (file)
@@ -31,7 +31,7 @@
 
 /*
  * Principal Author: Brian Wellington
- * $Id: dst_api.c,v 1.49 2010/01/11 23:48:37 tbox Exp $
+ * $Id: dst_api.c,v 1.50 2010/05/12 23:49:40 marka Exp $
  */
 
 /*! \file */
@@ -49,6 +49,7 @@
 #include <isc/lex.h>
 #include <isc/mem.h>
 #include <isc/once.h>
+#include <isc/platform.h>
 #include <isc/print.h>
 #include <isc/random.h>
 #include <isc/string.h>
@@ -1346,9 +1347,16 @@ issymmetric(const dst_key_t *key) {
 static void
 printtime(const dst_key_t *key, int type, const char *tag, FILE *stream) {
        isc_result_t result;
+#ifdef ISC_PLATFORM_USETHREADS
+       char output[26]; /* Minimum buffer as per ctime_r() specification. */
+#else
        const char *output;
+#endif
        isc_stdtime_t when;
        time_t t;
+       char utc[sizeof("YYYYMMDDHHSSMM")];
+       isc_buffer_t b;
+       isc_region_t r;
 
        result = dst_key_gettime(key, type, &when);
        if (result == ISC_R_NOTFOUND)
@@ -1356,8 +1364,30 @@ printtime(const dst_key_t *key, int type, const char *tag, FILE *stream) {
 
        /* time_t and isc_stdtime_t might be different sizes */
        t = when;
+#ifdef ISC_PLATFORM_USETHREADS
+#ifdef WIN32
+       if (ctime_s(output, sizeof(output), &t) != 0)
+               goto error;
+#else
+       if (ctime_r(&t, outout) == NULL)
+               goto error;
+#endif
+#else
        output = ctime(&t);
-       fprintf(stream, "%s: %s", tag, output);
+#endif
+
+       isc_buffer_init(&b, utc, sizeof(utc));
+       result = dns_time32_totext(when, &b);
+       if (result != ISC_R_SUCCESS)
+               goto error;
+
+       isc_buffer_usedregion(&b, &r);
+       fprintf(stream, "%s: %.*s (%.*s)\n", tag, (int)r.length, r.base,
+                strlen(output) - 1, output);
+       return;
+
+ error:
+       fprintf(stream, "%s: (set, unable to display)\n", tag);
 }
 
 /*%