Skip to content

Commit

Permalink
syscall: fix a Y2038 bug by replacing Int32x32To64 with multiplication
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
CookiePLMonster committed Jan 13, 2025
1 parent 3621202 commit 0a1c572
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ int do_SetFileTime(const char *path, time_t crtime)
free(pathw);
if (handle == INVALID_HANDLE_VALUE)
return -1;
int64 temp_time = Int32x32To64(crtime, 10000000) + 116444736000000000LL;
int64 temp_time = (crtime * 10000000LL) + 116444736000000000LL;
FILETIME birth_time;
birth_time.dwLowDateTime = (DWORD)temp_time;
birth_time.dwHighDateTime = (DWORD)(temp_time >> 32);
Expand Down

0 comments on commit 0a1c572

Please sign in to comment.