Open LainOTN2 opened 1 month ago
Thanks. Looks like that would need some compat implementation of gettimeofday via GetSystemTime and SystemTimeToFileTime or something like that.
Would be nice if the OS provided a fix on the system level rather than requiring downstreams to come up with workarounds for its brokenness...
The funcion is already compat implemented here: https://github.com/libressl/portable/blob/cd0ae0ef32d308a4704006b4514e2d065ed8df3c/crypto/compat/posix_win.c#L292
but when declaring
we are taking the timeval declaration from winsock2.h, that is a signed 32 bits.
Right. I need to fix the aggressive .gitignore
...
If we're lucky, the diff below works. I'm unsure how posix_win.c
ends up pulling in sys/time.h
, perhaps it needs an explicit such include somewhere at the top.
diff --git a/include/compat/sys/time.h b/include/compat/sys/time.h
index 76428c1..2448969 100644
--- a/include/compat/sys/time.h
+++ b/include/compat/sys/time.h
@@ -8,6 +8,15 @@
#ifdef _MSC_VER
#include <winsock2.h>
+
+#define timeval libressl_timeval
+#define gettimeofday libressl_gettimeofday
+
+struct timeval {
+ long long tv_sec;
+ long tv_usec;
+};
+
int gettimeofday(struct timeval *tp, void *tzp);
#else
#include_next <sys/time.h>
See #1078. It would be great if you could check if this addresses the issue.
MSVC gettimeofday implementation rely on the definition of timeval provided by winsock2.h https://learn.microsoft.com/en-us/windows/win32/api/winsock2/ns-winsock2-timeval
typedef struct timeval { long tv_sec; long tv_usec; } TIMEVAL, PTIMEVAL, LPTIMEVAL;
this give us potential errors when dealing with dates bigger than the year 2038, i.e. OpenSSH-Portable hangs if the machine date is set to a year bigger than 2039
Connection is stuck when time on SSH Server is set after the Year-2038 Problem