diff --git a/options.c b/options.c index 578507c6e..2cbdf30da 100644 --- a/options.c +++ b/options.c @@ -1156,7 +1156,7 @@ static time_t parse_time(const char *arg) { const char *cp; time_t val, now = time(NULL); - struct tm t, *today = localtime(&now); + struct tm t, tmp, *today = localtime_r(&now, &tmp); int in_date, old_mday, n; memset(&t, 0, sizeof t); diff --git a/tls.c b/tls.c index 858f8f10c..7811e1fc3 100644 --- a/tls.c +++ b/tls.c @@ -127,7 +127,7 @@ static void storetime(char *dest, size_t destsize, time_t t, int nsecs) { if (t) { int len; - struct tm *mt = gmtime(&t); + struct tm tmp, *mt = gmtime_r(&t, &tmp); len = snprintf(dest, destsize, " %04d-%02d-%02d %02d:%02d:%02d", diff --git a/util1.c b/util1.c index d84bc4140..231d22065 100644 --- a/util1.c +++ b/util1.c @@ -1389,7 +1389,7 @@ char *timestring(time_t t) static int ndx = 0; static char buffers[4][20]; /* We support 4 simultaneous timestring results. */ char *TimeBuf = buffers[ndx = (ndx + 1) % 4]; - struct tm *tm = localtime(&t); + struct tm tmp, *tm = localtime_r(&t, &tmp); int len = snprintf(TimeBuf, sizeof buffers[0], "%4d/%02d/%02d %02d:%02d:%02d", (int)tm->tm_year + 1900, (int)tm->tm_mon + 1, (int)tm->tm_mday, (int)tm->tm_hour, (int)tm->tm_min, (int)tm->tm_sec);