Fix a Y2038 bug by replacing Int32x32To64 with regular multiplication (#2471)

`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.

I detailed this issue a while ago in a writeup, and spotted the same
issue in this repository when updating the list of affected
repositories:
<https://cookieplmonster.github.io/2022/02/17/year-2038-problem/>

A few more notes:
1. I changed all uses of `Int32x32To64` en masse, even though at least
one of them was technically OK and used with int32 parameters only. IMO
better safe than sorry.
2. This is untested, but it's a small enough change that I hope the CI
success is a good enough indicator.
This commit is contained in:
Silent authored and GitHub committed 2025-01-01 08:31:35 -08:00
1 parent 25c3d9afea
commit 14b8803c40
3 files changed
+3 -3

No files matched your search

+1 -1
View File
@@ -2108,7 +2108,7 @@ assertion_utimes(const char *file, int line, const char *pathname,
int r;
#if defined(_WIN32) && !defined(__CYGWIN__)
#define WINTIME(sec, nsec) ((Int32x32To64(sec, 10000000) + EPOC_TIME)\
#define WINTIME(sec, nsec) (((sec * 10000000LL) + EPOC_TIME)\
+ (((nsec)/1000)*10))
HANDLE h;
ULARGE_INTEGER wintm;