Win32: Fix a Y2038 bug in TimeToSystemTime (#16681)

This commit is contained in:
Silent 2022-02-18 11:22:29 +01:00 committed by GitHub
parent 2b4579bd93
commit 2ac24e7c3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -185,11 +185,12 @@ namespace Platform
static SYSTEMTIME TimeToSystemTime(std::time_t timestamp)
{
LONGLONG ll = Int32x32To64(timestamp, 10000000) + 116444736000000000;
ULARGE_INTEGER time_value;
time_value.QuadPart = (timestamp * 10000000LL) + 116444736000000000LL;
FILETIME ft;
ft.dwLowDateTime = static_cast<DWORD>(ll);
ft.dwHighDateTime = ll >> 32;
ft.dwLowDateTime = time_value.LowPart;
ft.dwHighDateTime = time_value.HighPart;
SYSTEMTIME st;
FileTimeToSystemTime(&ft, &st);