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

Unified Diff: components/policy/core/common/preg_parser_fuzzer.cc

Issue 2791193005: Add fuzzer test for preg_parser (Closed)
Patch Set: Compile preg parser on Linux 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 side-by-side diff with in-line comments
Download patch
Index: components/policy/core/common/preg_parser_fuzzer.cc
diff --git a/components/policy/core/common/preg_parser_fuzzer.cc b/components/policy/core/common/preg_parser_fuzzer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..aff354471256b171a80f9513a4577a5d11edc1c5
--- /dev/null
+++ b/components/policy/core/common/preg_parser_fuzzer.cc
@@ -0,0 +1,44 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <base/strings/utf_string_conversions.h>
+#include "base/strings/string16.h"
+
+#include "components/policy/core/common/policy_load_status.h"
+#include "components/policy/core/common/preg_parser.h"
+#include "components/policy/core/common/registry_dict.h"
+
+namespace {
+
+const char kRegistryChromePolicyKey[] = "SOFTWARE\\Policies\\Chromium";
+
+} // namespace
+
+namespace policy {
+namespace preg_parser {
+
+// Disable logging.
+struct Environment {
+ Environment() : root(base::ASCIIToUTF16(kRegistryChromePolicyKey)) {
+ logging::SetMinLogLevel(logging::LOG_FATAL);
+ }
+
+ const base::string16 root;
+};
+
+Environment* env = new Environment();
+
+// Entry point for LibFuzzer.
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ RegistryDict dict;
+ PolicyLoadStatus status;
+ ReadDataInternal(data, size, env->root, &dict, &status, "data");
+ return 0;
+}
+
+} // namespace preg_parser
+} // namespace policy
« components/policy/core/common/preg_parser.cc ('K') | « components/policy/core/common/preg_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698