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

Side by Side 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, 9 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 | « net/base/parse_ip_pattern_fuzzer.cc ('k') | net/base/sniff_mime_type_fuzzer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/at_exit.h"
6 #include "base/i18n/icu_util.h"
7 #include "base/strings/string_piece.h"
8 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
9 #include "url/gurl.h"
10
11 // Initialize ICU.
12 struct InitICU {
13 InitICU() { CHECK(base::i18n::InitializeICU()); }
14 base::AtExitManager at_exit_manager;
15 };
16
17 InitICU* init_icu = new InitICU();
18
19 // Entry point for LibFuzzer.
20 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
21 net::registry_controlled_domains::PrivateRegistryFilter filter =
22 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES;
23
24 // Consume the first byte to determine which filter mode to use.
25 if (size > 0) {
26 uint8_t first_byte = *data;
27 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 :)
28 if ((first_byte % 2) == 1)
29 filter = net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES;
30 }
31
32 std::string input(data, data + size);
mmoroz 2016/02/26 09:18:45 Unused variable |input|?
eroman 2016/02/26 20:37:19 Fixed.
33
34 net::registry_controlled_domains::GetDomainAndRegistry(
35 base::StringPiece(reinterpret_cast<const char*>(data), size), filter);
36
37 return 0;
38 }
OLDNEW
« 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