Replaced localtime with localtime_r
authorakallabeth <akallabeth@posteo.net>
Mon, 25 May 2020 11:56:24 +0000 (13:56 +0200)
committerArmin Novak <armin.novak@thincast.com>
Mon, 22 Jun 2020 10:11:54 +0000 (12:11 +0200)
(cherry picked from commit 240fdd07b123594a1f7a460de7e6877b1963d09e)

channels/printer/client/cups/printer_cups.c
channels/printer/client/win/printer_win.c
winpr/libwinpr/sysinfo/sysinfo.c
winpr/libwinpr/timezone/timezone.c

index 1f9f07b..56cbace 100644 (file)
@@ -69,10 +69,11 @@ struct rdp_cups_print_job
 static void printer_cups_get_printjob_name(char* buf, size_t size, size_t id)
 {
        time_t tt;
+       struct tm tres;
        struct tm* t;
 
        tt = time(NULL);
-       t = localtime(&tt);
+       t = localtime_r(&tt, &tres);
        sprintf_s(buf, size - 1, "FreeRDP Print %04d-%02d-%02d %02d-%02d-%02d - Job %" PRIdz,
                  t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, id);
 }
index 5306f59..83dadba 100644 (file)
@@ -78,13 +78,14 @@ struct rdp_win_print_job
 static WCHAR* printer_win_get_printjob_name(size_t id)
 {
        time_t tt;
+       struct tm tres;
        struct tm* t;
        WCHAR* str;
        size_t len = 1024;
        int rc;
 
        tt = time(NULL);
-       t = localtime(&tt);
+       t = localtime_r(&tt, &tres);
 
        str = calloc(len, sizeof(WCHAR));
        if (!str)
index 10884f7..139d654 100644 (file)
@@ -242,11 +242,12 @@ BOOL SetSystemTime(CONST SYSTEMTIME* lpSystemTime)
 VOID GetLocalTime(LPSYSTEMTIME lpSystemTime)
 {
        time_t ct = 0;
+       struct tm tres;
        struct tm* ltm = NULL;
        WORD wMilliseconds = 0;
        ct = time(NULL);
        wMilliseconds = (WORD)(GetTickCount() % 1000);
-       ltm = localtime(&ct);
+       ltm = localtime_r(&ct, &tres);
        ZeroMemory(lpSystemTime, sizeof(SYSTEMTIME));
 
        if (ltm)
index 5475cb6..5077638 100644 (file)
@@ -339,12 +339,17 @@ winpr_get_current_time_zone_rule(const TIME_ZONE_RULE_ENTRY* rules, UINT32 count
 DWORD GetTimeZoneInformation(LPTIME_ZONE_INFORMATION lpTimeZoneInformation)
 {
        time_t t;
+       struct tm tres;
+       ;
        struct tm* local_time;
        TIME_ZONE_ENTRY* dtz;
        LPTIME_ZONE_INFORMATION tz = lpTimeZoneInformation;
        lpTimeZoneInformation->StandardBias = 0;
        time(&t);
-       local_time = localtime(&t);
+       local_time = localtime_r(&t, &tres);
+       if (!local_time)
+               goto out_error;
+
        memset(tz, 0, sizeof(TIME_ZONE_INFORMATION));
 #ifdef HAVE_TM_GMTOFF
        {