• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 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 #ifdef UNSAFE_BUFFERS_BUILD
6 // TODO(crbug.com/40284755): Remove this and spanify to fix the errors.
7 #pragma allow_unsafe_buffers
8 #endif
9 
10 #include <memory>
11 #include <string>
12 
13 #include "net/base/network_isolation_key.h"
14 #include "net/dns/mock_host_resolver.h"
15 #include "net/http/http_auth_handler.h"
16 #include "net/http/http_auth_handler_basic.h"
17 #include "net/log/net_log_with_source.h"
18 #include "net/ssl/ssl_info.h"
19 #include "url/gurl.h"
20 #include "url/scheme_host_port.h"
21 
LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)22 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
23   std::string input(reinterpret_cast<const char*>(data), size);
24   std::string challenge = "Basic " + input;
25 
26   // Dummies
27   net::SSLInfo null_ssl_info;
28   url::SchemeHostPort scheme_host_port(GURL("https://foo.test/"));
29   auto host_resolver = std::make_unique<net::MockHostResolver>();
30   std::unique_ptr<net::HttpAuthHandler> basic;
31 
32   net::HttpAuthHandlerBasic::Factory factory;
33   factory.CreateAuthHandlerFromString(
34       challenge, net::HttpAuth::AUTH_SERVER, null_ssl_info,
35       net::NetworkAnonymizationKey(), scheme_host_port, net::NetLogWithSource(),
36       host_resolver.get(), &basic);
37   return 0;
38 }
39