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]
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/*%
|
||||
|
||||
Reference in New Issue
Block a user