dns_hosts_parse_fuzzer.cc 763 B

12345678910111213141516171819202122
  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. #include <stddef.h>
  5. #include <stdint.h>
  6. #include <string>
  7. #include "net/dns/dns_hosts.h"
  8. // Entry point for LibFuzzer.
  9. extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  10. std::string input(reinterpret_cast<const char*>(data), size);
  11. net::DnsHosts dns_hosts;
  12. net::ParseHostsWithCommaModeForTesting(input, &dns_hosts,
  13. net::PARSE_HOSTS_COMMA_IS_TOKEN);
  14. dns_hosts.clear();
  15. net::ParseHostsWithCommaModeForTesting(input, &dns_hosts,
  16. net::PARSE_HOSTS_COMMA_IS_WHITESPACE);
  17. return 0;
  18. }