From: Nathanael P Wilson Date: Tue, 3 Jan 2023 23:10:36 +0000 (-0800) Subject: Replace potentially dangerous localtime function X-Git-Tag: v12.7.2~14^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8e534c96bf7c14f7722d340fa42529c98dd65899;p=sysstat Replace potentially dangerous localtime function --- diff --git a/sa_common.c b/sa_common.c index 3fe866a..7bef23d 100644 --- a/sa_common.c +++ b/sa_common.c @@ -663,10 +663,11 @@ int decode_epoch(char timestamp[], struct tstamp *tse) tse->epoch = epoch_time; tse->use_epoch = TRUE; - struct tm *given_time = localtime(&epoch_time); - tse->tm_sec = given_time->tm_sec; - tse->tm_min = given_time->tm_min; - tse->tm_hour = given_time->tm_hour; + struct tm given_time; + localtime_r(&epoch_time, &given_time); + tse->tm_sec = given_time.tm_sec; + tse->tm_min = given_time.tm_min; + tse->tm_hour = given_time.tm_hour; tse->use = TRUE; return 0;