OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |