diff --git a/CHANGES b/CHANGES index f46298e90c..fd49e6fa3c 100644 --- 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] diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c index 468aac1138..8be1286b1f 100644 --- a/lib/dns/dst_api.c +++ b/lib/dns/dst_api.c @@ -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 #include #include +#include #include #include #include @@ -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); } /*%