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

Side by Side Diff: chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.cc

Issue 1719983005: base: Stop overloading ReadFileToString() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix errors Created 4 years, 10 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 | « base/files/file_util_unittest.cc ('k') | chrome/browser/ui/webui/test_files_request_filter.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 void UserCloudPolicyStoreChromeOS::LoadPolicyKey(const base::FilePath& path, 493 void UserCloudPolicyStoreChromeOS::LoadPolicyKey(const base::FilePath& path,
494 std::string* key) { 494 std::string* key) {
495 if (!base::PathExists(path)) { 495 if (!base::PathExists(path)) {
496 // There is no policy key the first time that a user fetches policy. If 496 // There is no policy key the first time that a user fetches policy. If
497 // |path| does not exist then that is the most likely scenario, so there's 497 // |path| does not exist then that is the most likely scenario, so there's
498 // no need to sample a failure. 498 // no need to sample a failure.
499 VLOG(1) << "No key at " << path.value(); 499 VLOG(1) << "No key at " << path.value();
500 return; 500 return;
501 } 501 }
502 502
503 const bool read_success = base::ReadFileToString(path, key, kKeySizeLimit); 503 const bool read_success =
504 base::ReadFileToStringWithMaxSize(path, key, kKeySizeLimit);
504 // If the read was successful and the file size is 0 or if the read fails 505 // If the read was successful and the file size is 0 or if the read fails
505 // due to file size exceeding |kKeySizeLimit|, log error. 506 // due to file size exceeding |kKeySizeLimit|, log error.
506 if ((read_success && key->length() == 0) || 507 if ((read_success && key->length() == 0) ||
507 (!read_success && key->length() == kKeySizeLimit)) { 508 (!read_success && key->length() == kKeySizeLimit)) {
508 LOG(ERROR) << "Key at " << path.value() 509 LOG(ERROR) << "Key at " << path.value()
509 << (read_success ? " is empty." : " exceeds size limit"); 510 << (read_success ? " is empty." : " exceeds size limit");
510 key->clear(); 511 key->clear();
511 } else if (!read_success) { 512 } else if (!read_success) {
512 LOG(ERROR) << "Failed to read key at " << path.value(); 513 LOG(ERROR) << "Failed to read key at " << path.value();
513 } 514 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 const std::string empty_key = std::string(); 564 const std::string empty_key = std::string();
564 // The policy loaded from session manager need not be validated using the 565 // The policy loaded from session manager need not be validated using the
565 // verification key since it is secure, and since there may be legacy policy 566 // verification key since it is secure, and since there may be legacy policy
566 // data that was stored without a verification key. Hence passing an empty 567 // data that was stored without a verification key. Hence passing an empty
567 // value for the verification key. 568 // value for the verification key.
568 validator->ValidateSignature( 569 validator->ValidateSignature(
569 policy_key_, empty_key, ExtractDomain(username_), allow_rotation); 570 policy_key_, empty_key, ExtractDomain(username_), allow_rotation);
570 return validator; 571 return validator;
571 } 572 }
572 } // namespace policy 573 } // namespace policy
OLDNEW
« no previous file with comments | « base/files/file_util_unittest.cc ('k') | chrome/browser/ui/webui/test_files_request_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698