Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a Y2038 bug in timeToFILETIME #145

Merged
merged 1 commit into from
Nov 18, 2022
Merged

Fix a Y2038 bug in timeToFILETIME #145

merged 1 commit into from
Nov 18, 2022

Conversation

CookiePLMonster
Copy link
Contributor

The old code truncated time_t to a 32-bit value when using Int32x32To64. This example code has been fixed on MSDN a while ago, so this change only updates it to the current version.

While this function is currently unused by ghc, it resides in a public header so someone could have relied on it.

This PR is a part of a mini-project dedicated to fixing Y2038 problems caused by this very code snippet.
https://cookieplmonster.github.io/2022/02/17/year-2038-problem/

@phprus
Copy link
Contributor

phprus commented May 23, 2022

@CookiePLMonster,
Please fix the compilation error in Mingw (AppVeyor CI).

[  5%] Building CXX object test/CMakeFiles/filesystem_test.dir/filesystem_test.cpp.obj
In file included from C:\projects\filesystem\test\filesystem_test.cpp:62:0:
C:/projects/filesystem/include/ghc/filesystem.hpp: In function 'void ghc::filesystem::detail::timeToFILETIME(time_t, FILETIME&)':
C:/projects/filesystem/include/ghc/filesystem.hpp:2245:37: error: conversion to 'ULONGLONG {aka long long unsigned int}' from 'long long int' may change the sign of the result [-Werror=sign-conversion]
     ull.QuadPart = (t * 10000000LL) + 116444736000000000LL;
                    ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
cc1plus.exe: all warnings being treated as errors

The old code truncated time_t to a 32-bit value
when using Int32x32To64. This example code has been fixed
on MSDN a while ago, so this change only updates it to
the current version.

More on this issue:
https://cookieplmonster.github.io/2022/02/17/year-2038-problem/
@gulrak gulrak added bug Something isn't working Windows Windows platform is affected labels Jun 15, 2022
@gulrak gulrak added this to the v1.5.14 milestone Jun 15, 2022
@gulrak
Copy link
Owner

gulrak commented Nov 18, 2022

Thank you for the PR and sorry for the very long delay.

@gulrak gulrak merged commit 3e5b930 into gulrak:master Nov 18, 2022
@gulrak gulrak added the available on master Fix is done on master branch, issue closed on next release label Nov 18, 2022
@CookiePLMonster CookiePLMonster deleted the y2038-fix branch November 18, 2022 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
available on master Fix is done on master branch, issue closed on next release bug Something isn't working Windows Windows platform is affected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants