1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-12-24 17:19:52 +03:00

src/Mayaqua/Kernel.c: Fix for times before 1970

Before, it would end up far in the future. Now it gets clamped
to 1970. This should be fine since dates before 1970 are not
actively used. If they are, then the UINT64 should be replaced
by the time64t in quite a few places.
This commit is contained in:
Johan de Vries 2018-06-21 09:29:36 +02:00
parent 3d0e87cf57
commit 41f9cdadc4

View File

@ -2137,6 +2137,15 @@ UINT64 SystemToUINT64(SYSTEMTIME *st)
}
time = SystemToTime(st);
//For times before 1970-01-01, clamp to the minimum
//because we have to return an unsigned integer.
//This is less wrong than casting it to UINT64
//and returning a time far in the future.
//For some reason we subtract 9 hours below, so
//account for that here.
if( time < 32400000LL ) return 0;
sec64 = (UINT64)time * (UINT64)1000;
sec64 += st->wMilliseconds;