From d42683c042ac427a8824aa9913c0c82beeae6757 Mon Sep 17 00:00:00 2001 From: Silent Date: Mon, 30 Dec 2024 18:55:39 +0100 Subject: [PATCH] Fix a Y2038 bug by replacing Int32x32To64 with regular multiplication Int32x32To64 macro internally truncates the arguments to int32, while time_t is 64-bit on most/all modern platforms. Therefore, usage of this macro creates a Year 2038 bug. --- localization.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/localization.c b/localization.c index 6871a49..bb90576 100644 --- a/localization.c +++ b/localization.c @@ -189,7 +189,7 @@ LocalizedTime(const time_t t, LPTSTR buf, size_t size) /* Convert Unix timestamp to Win32 SYSTEMTIME */ FILETIME lft; SYSTEMTIME st; - LONGLONG tmp = Int32x32To64(t, 10000000) + 116444736000000000; + LONGLONG tmp = (t * 10000000LL) + 116444736000000000LL; FILETIME ft = { .dwLowDateTime = (DWORD) tmp, .dwHighDateTime = tmp >> 32}; FileTimeToLocalFileTime(&ft, &lft); FileTimeToSystemTime(&lft, &st);