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

Side by Side Diff: base/test/test_reg_util_win.cc

Issue 519773002: Fix out-of-bounds read in RegistryOverrideManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/test/test_reg_util_win.h" 5 #include "base/test/test_reg_util_win.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 15 matching lines...) Expand all
26 KEY_ALL_ACCESS) != ERROR_SUCCESS) { 26 KEY_ALL_ACCESS) != ERROR_SUCCESS) {
27 // This will occur on first-run, but is harmless. 27 // This will occur on first-run, but is harmless.
28 return; 28 return;
29 } 29 }
30 30
31 base::win::RegistryKeyIterator iterator_test_root_key(HKEY_CURRENT_USER, 31 base::win::RegistryKeyIterator iterator_test_root_key(HKEY_CURRENT_USER,
32 test_key_root.c_str()); 32 test_key_root.c_str());
33 for (; iterator_test_root_key.Valid(); ++iterator_test_root_key) { 33 for (; iterator_test_root_key.Valid(); ++iterator_test_root_key) {
34 base::string16 key_name = iterator_test_root_key.Name(); 34 base::string16 key_name = iterator_test_root_key.Name();
35 std::vector<base::string16> tokens; 35 std::vector<base::string16> tokens;
36 Tokenize(key_name, base::string16(kTimestampDelimiter), &tokens); 36 if (!Tokenize(key_name, base::string16(kTimestampDelimiter), &tokens))
37 continue;
37 int64 key_name_as_number = 0; 38 int64 key_name_as_number = 0;
38 39
39 if (!base::StringToInt64(tokens[0], &key_name_as_number)) { 40 if (!base::StringToInt64(tokens[0], &key_name_as_number)) {
40 test_root_key.DeleteKey(key_name.c_str()); 41 test_root_key.DeleteKey(key_name.c_str());
41 continue; 42 continue;
42 } 43 }
43 44
44 base::Time key_time = base::Time::FromInternalValue(key_name_as_number); 45 base::Time key_time = base::Time::FromInternalValue(key_name_as_number);
45 base::TimeDelta age = now - key_time; 46 base::TimeDelta age = now - key_time;
46 47
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 base::string16 key_path = GenerateTempKeyPath(test_key_root_, timestamp_); 98 base::string16 key_path = GenerateTempKeyPath(test_key_root_, timestamp_);
98 overrides_.push_back(new ScopedRegistryKeyOverride(override, key_path)); 99 overrides_.push_back(new ScopedRegistryKeyOverride(override, key_path));
99 } 100 }
100 101
101 base::string16 GenerateTempKeyPath() { 102 base::string16 GenerateTempKeyPath() {
102 return GenerateTempKeyPath(base::string16(kTempTestKeyPath), 103 return GenerateTempKeyPath(base::string16(kTempTestKeyPath),
103 base::Time::Now()); 104 base::Time::Now());
104 } 105 }
105 106
106 } // namespace registry_util 107 } // namespace registry_util
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698