Index: chrome/installer/util/google_update_settings.cc |
diff --git a/chrome/installer/util/google_update_settings.cc b/chrome/installer/util/google_update_settings.cc |
index e32e185d354c26607c7908f55f5c52ebb02a78c3..6ed2852de7797fcf4adba45b12e75797bde10438 100644 |
--- a/chrome/installer/util/google_update_settings.cc |
+++ b/chrome/installer/util/google_update_settings.cc |
@@ -8,6 +8,7 @@ |
#include <algorithm> |
#include <limits> |
+#include <vector> |
#include "base/command_line.h" |
#include "base/files/file_path.h" |
@@ -36,6 +37,8 @@ using installer::InstallationState; |
const wchar_t GoogleUpdateSettings::kPoliciesKey[] = |
L"SOFTWARE\\Policies\\Google\\Update"; |
const wchar_t GoogleUpdateSettings::kUpdatePolicyValue[] = L"UpdateDefault"; |
+const wchar_t GoogleUpdateSettings::kDownloadPreferencePolicyValue[] = |
+ L"DownloadPreference"; |
const wchar_t GoogleUpdateSettings::kUpdateOverrideValuePrefix[] = L"Update"; |
const wchar_t GoogleUpdateSettings::kCheckPeriodOverrideMinutes[] = |
L"AutoUpdateCheckPeriodMinutes"; |
@@ -770,6 +773,30 @@ bool GoogleUpdateSettings::ReenableAutoupdates() { |
return true; |
} |
+// Reads and sanitizes the value of |
+// "HKLM\SOFTWARE\Policies\Google\Update\DownloadPreference". A valid |
+// group policy option must be a single alpha numeric word of up to 32 |
+// characters. |
+base::string16 GoogleUpdateSettings::GetDownloadPreference() { |
+ RegKey policy_key; |
+ base::string16 value; |
+ if (policy_key.Open(HKEY_LOCAL_MACHINE, kPoliciesKey, KEY_QUERY_VALUE) == |
+ ERROR_SUCCESS && |
+ policy_key.ReadValue(kDownloadPreferencePolicyValue, &value) == |
+ ERROR_SUCCESS) { |
+ // Validates that |value| matches `[a-zA-z]{0-32}`. |
+ const size_t kMaxValueLength = 32; |
+ if (value.size() > kMaxValueLength) |
+ return base::string16(); |
+ for (auto ch : value) { |
+ if (!base::IsAsciiAlpha(ch)) |
+ return base::string16(); |
+ } |
+ return value; |
+ } |
+ return base::string16(); |
+} |
+ |
void GoogleUpdateSettings::RecordChromeUpdatePolicyHistograms() { |
const bool is_multi_install = InstallUtil::IsMultiInstall( |
BrowserDistribution::GetDistribution(), IsSystemInstall()); |