Replaced localtime with localtime_r

This commit is contained in:
akallabeth 2020-05-25 13:56:24 +02:00 committed by Armin Novak
parent 057b6df4ae
commit 240fdd07b1
4 changed files with 12 additions and 4 deletions

View 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);
}

View 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)

View 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)

View 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
{