Skip to content

Commit d7e84c6

Browse files
Fix a Y2038 bug by replacing Int32x32To64 with regular multiplication
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.
1 parent 5beaf27 commit d7e84c6

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

libsql-ffi/bundled/SQLite3MultipleCiphers/src/fileio.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ static int writeFile(
428428

429429
GetSystemTime(&currentTime);
430430
SystemTimeToFileTime(&currentTime, &lastAccess);
431-
intervals = Int32x32To64(mtime, 10000000) + 116444736000000000;
431+
intervals = (mtime * 10000000LL) + 116444736000000000LL;
432432
lastWrite.dwLowDateTime = (DWORD)intervals;
433433
lastWrite.dwHighDateTime = intervals >> 32;
434434
zUnicodeName = sqlite3_win32_utf8_to_unicode(zFile);

libsql-ffi/bundled/SQLite3MultipleCiphers/src/shell.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -7514,7 +7514,7 @@ static int writeFile(
75147514

75157515
GetSystemTime(&currentTime);
75167516
SystemTimeToFileTime(&currentTime, &lastAccess);
7517-
intervals = Int32x32To64(mtime, 10000000) + 116444736000000000;
7517+
intervals = (mtime * 10000000LL) + 116444736000000000LL;
75187518
lastWrite.dwLowDateTime = (DWORD)intervals;
75197519
lastWrite.dwHighDateTime = intervals >> 32;
75207520
zUnicodeName = sqlite3_win32_utf8_to_unicode(zFile);

libsql-sqlite3/ext/misc/fileio.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ static int writeFile(
428428

429429
GetSystemTime(&currentTime);
430430
SystemTimeToFileTime(&currentTime, &lastAccess);
431-
intervals = Int32x32To64(mtime, 10000000) + 116444736000000000;
431+
intervals = (mtime * 10000000LL) + 116444736000000000LL;
432432
lastWrite.dwLowDateTime = (DWORD)intervals;
433433
lastWrite.dwHighDateTime = intervals >> 32;
434434
zUnicodeName = sqlite3_win32_utf8_to_unicode(zFile);

0 commit comments

Comments
 (0)