Chromium Code Reviews| 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..083f6d9b87fce172e6d75a5e212a427513da6efd 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."; |
|
pneubeck (no reviews)
2014/02/17 16:07:40
nit:
since the GUID isn't a credential, we can as
|
| + 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; |