Index: chromeos/network/onc/onc_validator.cc |
diff --git a/chromeos/network/onc/onc_validator.cc b/chromeos/network/onc/onc_validator.cc |
index 675539041d4300d0e5299e922f9d028671e6c8bd..fcc6cacdff84f99a03c85a1a15293dcf6ad05cee 100644 |
--- a/chromeos/network/onc/onc_validator.cc |
+++ b/chromeos/network/onc/onc_validator.cc |
@@ -387,6 +387,21 @@ bool Validator::RequireField(const base::DictionaryValue& dict, |
return false; |
} |
+bool Validator::CheckGuidIsUniqueAndAddToSet(const base::DictionaryValue& dict, |
+ const std::string& key_guid, |
+ std::set<std::string> *guids) { |
+ std::string guid; |
+ if (dict.GetStringWithoutPathExpansion(key_guid, &guid)) { |
+ if (guids->count(guid) != 0) { |
+ error_or_warning_found_ = true; |
+ LOG(ERROR) << MessageHeader() << "Found a duplicate GUID " << guid << "."; |
+ return false; |
+ } |
+ guids->insert(guid); |
+ } |
+ return true; |
+} |
+ |
bool Validator::IsCertPatternInDevicePolicy(const std::string& cert_type) { |
if (cert_type == ::onc::certificate::kPattern && |
onc_source_ == ::onc::ONC_SOURCE_DEVICE_POLICY) { |
@@ -458,6 +473,9 @@ bool Validator::ValidateNetworkConfiguration(base::DictionaryValue* result) { |
return false; |
} |
+ if (!CheckGuidIsUniqueAndAddToSet(*result, kGUID, &network_guids_)) |
+ return false; |
+ |
bool all_required_exist = RequireField(*result, kGUID); |
bool remove = false; |
@@ -812,6 +830,9 @@ bool Validator::ValidateCertificate(base::DictionaryValue* result) { |
return false; |
} |
+ if (!CheckGuidIsUniqueAndAddToSet(*result, kGUID, &certificate_guids_)) |
+ return false; |
+ |
bool all_required_exist = RequireField(*result, kGUID); |
bool remove = false; |