Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: components/update_client/utils.cc

Issue 1876573002: Component updater must enforce that the brand length is 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@apchange
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/update_client/utils.h ('k') | components/update_client/utils_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/update_client/utils.h" 5 #include "components/update_client/utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 scoped_ptr<crypto::SecureHash> hasher( 224 scoped_ptr<crypto::SecureHash> hasher(
225 crypto::SecureHash::Create(crypto::SecureHash::SHA256)); 225 crypto::SecureHash::Create(crypto::SecureHash::SHA256));
226 hasher->Update(mmfile.data(), mmfile.length()); 226 hasher->Update(mmfile.data(), mmfile.length());
227 hasher->Finish(actual_hash, sizeof(actual_hash)); 227 hasher->Finish(actual_hash, sizeof(actual_hash));
228 228
229 return memcmp(actual_hash, &expected_hash[0], sizeof(actual_hash)) == 0; 229 return memcmp(actual_hash, &expected_hash[0], sizeof(actual_hash)) == 0;
230 } 230 }
231 231
232 bool IsValidBrand(const std::string& brand) { 232 bool IsValidBrand(const std::string& brand) {
233 const size_t kMaxBrandSize = 4; 233 const size_t kMaxBrandSize = 4;
234 if (brand.size() > kMaxBrandSize) 234 if (!brand.empty() && brand.size() != kMaxBrandSize)
235 return false; 235 return false;
236 236
237 return std::find_if_not(brand.begin(), brand.end(), [](char ch) { 237 return std::find_if_not(brand.begin(), brand.end(), [](char ch) {
238 return base::IsAsciiAlpha(ch); 238 return base::IsAsciiAlpha(ch);
239 }) == brand.end(); 239 }) == brand.end();
240 } 240 }
241 241
242 bool IsValidAp(const std::string& ap) { 242 bool IsValidAp(const std::string& ap) {
243 const size_t kMaxApSize = 256; 243 const size_t kMaxApSize = 256;
244 if (ap.size() > kMaxApSize) 244 if (ap.size() > kMaxApSize)
(...skipping 15 matching lines...) Expand all
260 260
261 void RemoveUnsecureUrls(std::vector<GURL>* urls) { 261 void RemoveUnsecureUrls(std::vector<GURL>* urls) {
262 DCHECK(urls); 262 DCHECK(urls);
263 urls->erase(std::remove_if( 263 urls->erase(std::remove_if(
264 urls->begin(), urls->end(), 264 urls->begin(), urls->end(),
265 [](const GURL& url) { return !url.SchemeIsCryptographic(); }), 265 [](const GURL& url) { return !url.SchemeIsCryptographic(); }),
266 urls->end()); 266 urls->end());
267 } 267 }
268 268
269 } // namespace update_client 269 } // namespace update_client
OLDNEW
« no previous file with comments | « components/update_client/utils.h ('k') | components/update_client/utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698