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

Unified Diff: net/base/registry_controlled_domains/get_domain_and_registry_fuzzer.cc

Issue 1735043004: Add fuzz testers to //net for some functions with simple parsing APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/parse_ip_pattern_fuzzer.cc ('k') | net/base/sniff_mime_type_fuzzer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/registry_controlled_domains/get_domain_and_registry_fuzzer.cc
diff --git a/net/base/registry_controlled_domains/get_domain_and_registry_fuzzer.cc b/net/base/registry_controlled_domains/get_domain_and_registry_fuzzer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e462d8d3812e8ccf61eea5a1f744ec0b130d5829
--- /dev/null
+++ b/net/base/registry_controlled_domains/get_domain_and_registry_fuzzer.cc
@@ -0,0 +1,38 @@
+// Copyright 2016 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 "base/at_exit.h"
+#include "base/i18n/icu_util.h"
+#include "base/strings/string_piece.h"
+#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
+#include "url/gurl.h"
+
+// Initialize ICU.
+struct InitICU {
+ InitICU() { CHECK(base::i18n::InitializeICU()); }
+ base::AtExitManager at_exit_manager;
+};
+
+InitICU* init_icu = new InitICU();
+
+// Entry point for LibFuzzer.
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ net::registry_controlled_domains::PrivateRegistryFilter filter =
+ net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES;
+
+ // Consume the first byte to determine which filter mode to use.
+ if (size > 0) {
+ uint8_t first_byte = *data;
+ size--;
mmoroz 2016/02/26 09:18:45 Since we use first byte of |data| and decrease |si
eroman 2016/02/26 20:37:19 Oops yes, that was my intent :)
+ if ((first_byte % 2) == 1)
+ filter = net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES;
+ }
+
+ std::string input(data, data + size);
mmoroz 2016/02/26 09:18:45 Unused variable |input|?
eroman 2016/02/26 20:37:19 Fixed.
+
+ net::registry_controlled_domains::GetDomainAndRegistry(
+ base::StringPiece(reinterpret_cast<const char*>(data), size), filter);
+
+ return 0;
+}
« no previous file with comments | « net/base/parse_ip_pattern_fuzzer.cc ('k') | net/base/sniff_mime_type_fuzzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698