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

Side by Side Diff: components/policy/core/common/preg_parser.h

Issue 2791193005: Add fuzzer test for preg_parser (Closed)
Patch Set: Renamed ReadData to ReadDataInternal and updated comment. Created 3 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 // This file provides a parser for PReg files which are used for storing group 5 // This file provides a parser for PReg files which are used for storing group
6 // policy settings in the file system. The file format is documented here: 6 // policy settings in the file system. The file format is documented here:
7 // 7 //
8 // http://msdn.microsoft.com/en-us/library/windows/desktop/aa374407(v=vs.85).asp x 8 // http://msdn.microsoft.com/en-us/library/windows/desktop/aa374407(v=vs.85).asp x
9 9
10 #ifndef COMPONENTS_POLICY_CORE_COMMON_PREG_PARSER_H_ 10 #ifndef COMPONENTS_POLICY_CORE_COMMON_PREG_PARSER_H_
11 #define COMPONENTS_POLICY_CORE_COMMON_PREG_PARSER_H_ 11 #define COMPONENTS_POLICY_CORE_COMMON_PREG_PARSER_H_
12 12
13 #include <memory> 13 #include <memory>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
17 #include "components/policy/core/common/policy_load_status.h"
Thiemo Nagel 2017/04/12 17:10:06 Why have you removed the forward declaration of Po
ljusten (tachyonic) 2017/04/13 11:17:15 The internal method takes a PolicyLoadStatus, whic
17 #include "components/policy/policy_export.h" 18 #include "components/policy/policy_export.h"
18 19
19 namespace base { 20 namespace base {
20 class FilePath; 21 class FilePath;
21 } 22 }
22 23
23 namespace policy { 24 namespace policy {
24 25
25 class PolicyLoadStatusSample;
26 class RegistryDict; 26 class RegistryDict;
27 27
28 namespace preg_parser { 28 namespace preg_parser {
29 29
30 // The magic header in PReg files: ASCII "PReg" + version (0x0001). 30 // The magic header in PReg files: ASCII "PReg" + version (0x0001).
31 POLICY_EXPORT extern const char kPRegFileHeader[8]; 31 POLICY_EXPORT extern const char kPRegFileHeader[8];
32 32
33 // Reads the PReg file at |file_path| and writes the registry data to |dict|. 33 // Reads the PReg file at |file_path| and writes the registry data to |dict|.
34 // |root| specifies the registry subtree the caller is interested in, 34 // |root| specifies the registry subtree the caller is interested in, everything
35 // everything else gets ignored. 35 // else gets ignored.
36 POLICY_EXPORT bool ReadFile(const base::FilePath& file_path, 36 POLICY_EXPORT bool ReadFile(const base::FilePath& file_path,
37 const base::string16& root, 37 const base::string16& root,
38 RegistryDict* dict, 38 RegistryDict* dict,
39 PolicyLoadStatusSample* status); 39 PolicyLoadStatusSample* status_sample);
40
41 // Similar to ReadFile, but reads from |data| of length |data_size| instead of
42 // a file, and writes status to the enum PolicyLoadStatus, which does not record
43 // UMA stats, unlike |PolicyLoadStatusSample|. |debug_name| is printed out along
44 // with error messages. Used internally only for testing. For production code,
Thiemo Nagel 2017/04/12 17:10:06 Nit: "only for testing" seems not correct as it's
ljusten (tachyonic) 2017/04/13 11:17:15 Clarified the wording.
45 // use ReadFile instead.
46 POLICY_EXPORT bool ReadDataInternal(const uint8_t* data,
47 size_t data_size,
48 const base::string16& root,
49 RegistryDict* dict,
50 PolicyLoadStatus* status,
Thiemo Nagel 2017/04/12 17:10:06 Nit: Returning a bool *and* updating |status| seem
ljusten (tachyonic) 2017/04/13 11:17:14 PolicyLoadStatus is used as UMA stat and does not
51 const std::string& debug_name);
40 52
41 } // namespace preg_parser 53 } // namespace preg_parser
42 } // namespace policy 54 } // namespace policy
43 55
44 #endif // COMPONENTS_POLICY_CORE_COMMON_PREG_PARSER_H_ 56 #endif // COMPONENTS_POLICY_CORE_COMMON_PREG_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698