1 // Copyright 2016 The Chromium Authors
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 <stddef.h>
6 #include <stdint.h>
7 
8 #include <string_view>
9 
10 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
11 #include "url/gurl.h"
12 
13 // Entry point for LibFuzzer.
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)14 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
15   // Call GetDomainAndRegistry() twice - once with each filter type to ensure
16   // both code paths are exercised.
17   net::registry_controlled_domains::GetDomainAndRegistry(
18       std::string_view(reinterpret_cast<const char*>(data), size),
19       net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
20 
21   net::registry_controlled_domains::GetDomainAndRegistry(
22       std::string_view(reinterpret_cast<const char*>(data), size),
23       net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
24 
25   return 0;
26 }
27