[W32TIME] Use a reasonable fallback of 9 hours. (#1724)

CORE-16181

This allows preventing spamming the time servers if the registry entry
becomes corrupted or missing. Also, disallow a setting of less than
2 minutes for the same reasons, and instead use the fallback of 9 hours.
This commit is contained in:
Benjamin Aerni 2019-07-12 23:42:10 -07:00 committed by Hermès Bélusca-Maïto
parent 7f59361911
commit 5b9543c31a
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -129,16 +129,18 @@ GetIntervalSetting(VOID)
LONG lRet;
dwData = 0;
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"SYSTEM\\CurrentControlSet\\Services\\W32Time\\TimeProviders\\NtpClient",
0,
KEY_QUERY_VALUE,
&hKey) == ERROR_SUCCESS)
lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"SYSTEM\\CurrentControlSet\\Services\\W32Time\\TimeProviders\\NtpClient",
0,
KEY_QUERY_VALUE,
&hKey);
if (lRet == ERROR_SUCCESS)
{
/* This key holds the update interval in seconds
* It is useful for testing to set it to a value of 10 (Decimal)
* This will cause the clock to try and update every 10 seconds
* So you can change the time and expect it to be set back correctly in 10-20 seconds
/*
* This key holds the update interval in seconds.
* It is useful for testing to set it to a value of 10 (Decimal).
* This will cause the clock to try and update every 10 seconds.
* So you can change the time and expect it to be set back correctly in 10-20 seconds.
*/
lRet = RegQueryValueExW(hKey,
L"SpecialPollInterval",
@ -149,8 +151,8 @@ GetIntervalSetting(VOID)
RegCloseKey(hKey);
}
if (lRet != ERROR_SUCCESS)
return 0;
if (lRet != ERROR_SUCCESS || dwData < 120)
return 9 * 60 * 60; // 9 hours, because Windows uses 9 hrs, 6 mins and 8 seconds by default.
else
return dwData;
}