]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
syscall: fix a Y2038 bug by replacing Int32x32To64 with multiplication
authorSilent <zdanio95@gmail.com>
Mon, 13 Jan 2025 14:01:06 +0000 (15:01 +0100)
committerAndrew Tridgell <andrew@tridgell.net>
Sat, 23 Aug 2025 07:32:11 +0000 (17:32 +1000)
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.

syscall.c

index 2287e16e04d3faab855f24a1dce3b2d1eb8e4815..ec0e0708a7403ab4de852e3c86d5eb9eb179f44b 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -480,7 +480,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);