summaryrefslogtreecommitdiff
path: root/lib/dns/dst_api.c
diff options
context:
space:
mode:
authorInternet Software Consortium, Inc <@isc.org>2010-06-21 09:47:35 -0600
committerInternet Software Consortium, Inc <@isc.org>2010-06-21 09:47:35 -0600
commitee8d640fb71bcd44bfa372f8489597b8e3d1f1a8 (patch)
tree536193ab70d7fb8e81155d1045f5ea7d7c2b4964 /lib/dns/dst_api.c
parent0530b53fd3266aed128be4120a332def55efd24d (diff)
downloadbind9-ee8d640fb71bcd44bfa372f8489597b8e3d1f1a8.tar.gz
9.7.1
Diffstat (limited to 'lib/dns/dst_api.c')
-rw-r--r--lib/dns/dst_api.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c
index 640c68ae..65791ed2 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.47.22.1 2010/01/13 19:31:52 each Exp $
+ * $Id: dst_api.c,v 1.47.22.3 2010/05/13 03:09:56 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, output) == 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,
+ (int)strlen(output) - 1, output);
+ return;
+
+ error:
+ fprintf(stream, "%s: (set, unable to display)\n", tag);
}
/*%