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.
pull/496/merge
Silent 2024-12-30 18:55:39 +01:00 committed by Selva Nair
parent 3ba02de7c6
commit 02137dd657
1 changed files with 1 additions and 1 deletions

View File

@ -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);