4738. [port] win32: strftime mishandles %Z. [RT #46039]

(cherry picked from commit 744061a03b)
This commit is contained in:
Mark Andrews
2017-09-26 23:33:26 +10:00
parent 6b183c64a3
commit aae171c542
2 changed files with 16 additions and 0 deletions
+2
View File
@@ -1,3 +1,5 @@
4738. [port] win32: strftime mishandles %Z. [RT #46039]
4737. [cleanup] Address Coverity warnings. [RT #46012]
4736. [cleanup] (a) Added comments to NSEC3-related functions in
+14
View File
@@ -244,7 +244,11 @@ received(int bytes, isc_sockaddr_t *from, dig_query_t *query) {
isc_uint64_t diff;
time_t tnow;
struct tm tmnow;
#ifdef WIN32
wchar_t time_str[100];
#else
char time_str[100];
#endif
char fromtext[ISC_SOCKADDR_FORMATSIZE];
isc_sockaddr_format(from, fromtext, sizeof(fromtext));
@@ -263,9 +267,19 @@ received(int bytes, isc_sockaddr_t *from, dig_query_t *query) {
tmnow = *localtime(&tnow);
#endif
#ifdef WIN32
/*
* On Windows, time zone name ("%Z") may be a localized
* wide-character string, which strftime() handles incorrectly.
*/
if (wcsftime(time_str, sizeof(time_str)/sizeof(time_str[0]),
"%a %b %d %H:%M:%S %Z %Y", &tmnow) > 0U)
printf(";; WHEN: %ls\n", time_str);
#else
if (strftime(time_str, sizeof(time_str),
"%a %b %d %H:%M:%S %Z %Y", &tmnow) > 0U)
printf(";; WHEN: %s\n", time_str);
#endif
if (query->lookup->doing_xfr) {
printf(";; XFR size: %u records (messages %u, "
"bytes %" ISC_PRINT_QUADFORMAT "u)\n",