https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5b9543c31a443cd997ee3…
commit 5b9543c31a443cd997ee357043ac4fc6119e8df2
Author: Benjamin Aerni <daprogramerforbatch(a)gmail.com>
AuthorDate: Fri Jul 12 23:42:10 2019 -0700
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Jul 21 17:47:13 2019 +0200
[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.
---
base/services/w32time/w32time.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/base/services/w32time/w32time.c b/base/services/w32time/w32time.c
index c32624f8b9a..d6a6828b637 100644
--- a/base/services/w32time/w32time.c
+++ b/base/services/w32time/w32time.c
@@ -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;
}