Fix localtime thread-safety issue - use localtime_r
authorIgor Kulaychuk <i.kulaychuk@samsung.com>
Thu, 13 Dec 2018 12:15:05 +0000 (15:15 +0300)
committerIgor Kulaychuk <i.kulaychuk@samsung.com>
Thu, 13 Dec 2018 12:23:39 +0000 (15:23 +0300)
logging.c

index ef85499a823e834f81e7148488738f9eea60fed8..e2d190ca10c71db08326e0a66e3312415c42db91 100644 (file)
--- a/logging.c
+++ b/logging.c
@@ -44,7 +44,8 @@ void log_set_file(FILE *file)
 
 void log_time_zone_info(time_t start_time)
 {
-       struct tm tm = *localtime(&start_time);
+       struct tm tm;
+       localtime_r(&start_time, &tm);
        fprintf(log_file, "Local time: %04d-%02d-%02d %02d:%02d:%02d. Time zone: %s (UTC",
                tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_zone);
        char sign;