]> granicus.if.org Git - sysstat/commitdiff
Replace potentially dangerous localtime function
authorNathanael P Wilson <Nathanael.P.Wilson@aexp.com>
Tue, 3 Jan 2023 23:10:36 +0000 (15:10 -0800)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 7 Jan 2023 13:48:18 +0000 (14:48 +0100)
sa_common.c

index 3fe866a881c3fd7ce7f0e67f8f307e0ac1bd5921..7bef23d01f576f2febdd1f8b6b0c17044caf0295 100644 (file)
@@ -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;