2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

4668. [bug] Use localtime_r and gmtime_r for thread safety.

[RT #45664]
This commit is contained in:
Mark Andrews
2017-08-03 08:42:27 +10:00
parent b9e4835f4b
commit 2019cf29e2
6 changed files with 85 additions and 6 deletions

View File

@@ -16,6 +16,7 @@
#include <isc/app.h>
#include <isc/netaddr.h>
#include <isc/parseint.h>
#include <isc/platform.h>
#include <isc/print.h>
#include <isc/string.h>
#include <isc/task.h>
@@ -261,7 +262,12 @@ received(int bytes, isc_sockaddr_t *from, dig_query_t *query) {
printf(";; Query time: %ld msec\n", (long) diff / 1000);
printf(";; SERVER: %s(%s)\n", fromtext, query->servname);
time(&tnow);
#if defined(ISC_PLATFORM_USETHREADS) && !defined(WIN32)
(void)localtime_r(&tnow, &tmnow);
#else
tmnow = *localtime(&tnow);
#endif
if (strftime(time_str, sizeof(time_str),
"%a %b %d %H:%M:%S %Z %Y", &tmnow) > 0U)
printf(";; WHEN: %s\n", time_str);