| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/http/http_proxy_client_socket.h" | 5 #include "net/http/http_proxy_client_socket.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/fuzzed_data_provider.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "net/base/address_list.h" | 16 #include "net/base/address_list.h" |
| 16 #include "net/base/auth.h" | 17 #include "net/base/auth.h" |
| 17 #include "net/base/fuzzed_data_provider.h" | |
| 18 #include "net/base/host_port_pair.h" | 18 #include "net/base/host_port_pair.h" |
| 19 #include "net/base/test_completion_callback.h" | 19 #include "net/base/test_completion_callback.h" |
| 20 #include "net/http/http_auth_cache.h" | 20 #include "net/http/http_auth_cache.h" |
| 21 #include "net/http/http_auth_handler_basic.h" | 21 #include "net/http/http_auth_handler_basic.h" |
| 22 #include "net/http/http_auth_handler_digest.h" | 22 #include "net/http/http_auth_handler_digest.h" |
| 23 #include "net/http/http_auth_handler_factory.h" | 23 #include "net/http/http_auth_handler_factory.h" |
| 24 #include "net/http/http_auth_scheme.h" | 24 #include "net/http/http_auth_scheme.h" |
| 25 #include "net/log/test_net_log.h" | 25 #include "net/log/test_net_log.h" |
| 26 #include "net/socket/client_socket_handle.h" | 26 #include "net/socket/client_socket_handle.h" |
| 27 #include "net/socket/fuzzed_socket.h" | 27 #include "net/socket/fuzzed_socket.h" |
| 28 #include "net/socket/next_proto.h" | 28 #include "net/socket/next_proto.h" |
| 29 | 29 |
| 30 // Fuzzer for HttpProxyClientSocket only tests establishing a connection when | 30 // Fuzzer for HttpProxyClientSocket only tests establishing a connection when |
| 31 // using the proxy as a tunnel. | 31 // using the proxy as a tunnel. |
| 32 // | 32 // |
| 33 // |data| is used to create a FuzzedSocket to fuzz reads and writes, see that | 33 // |data| is used to create a FuzzedSocket to fuzz reads and writes, see that |
| 34 // class for details. | 34 // class for details. |
| 35 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | 35 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 36 // Use a test NetLog, to exercise logging code. | 36 // Use a test NetLog, to exercise logging code. |
| 37 net::TestNetLog test_net_log; | 37 net::TestNetLog test_net_log; |
| 38 | 38 |
| 39 net::FuzzedDataProvider data_provider(data, size); | 39 base::FuzzedDataProvider data_provider(data, size); |
| 40 | 40 |
| 41 net::TestCompletionCallback callback; | 41 net::TestCompletionCallback callback; |
| 42 std::unique_ptr<net::FuzzedSocket> fuzzed_socket( | 42 std::unique_ptr<net::FuzzedSocket> fuzzed_socket( |
| 43 new net::FuzzedSocket(&data_provider, &test_net_log)); | 43 new net::FuzzedSocket(&data_provider, &test_net_log)); |
| 44 CHECK_EQ(net::OK, fuzzed_socket->Connect(callback.callback())); | 44 CHECK_EQ(net::OK, fuzzed_socket->Connect(callback.callback())); |
| 45 | 45 |
| 46 std::unique_ptr<net::ClientSocketHandle> socket_handle( | 46 std::unique_ptr<net::ClientSocketHandle> socket_handle( |
| 47 new net::ClientSocketHandle()); | 47 new net::ClientSocketHandle()); |
| 48 socket_handle->SetSocket(std::move(fuzzed_socket)); | 48 socket_handle->SetSocket(std::move(fuzzed_socket)); |
| 49 | 49 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 74 // Repeatedly try to log in with the same credentials. | 74 // Repeatedly try to log in with the same credentials. |
| 75 while (result == net::ERR_PROXY_AUTH_REQUESTED) { | 75 while (result == net::ERR_PROXY_AUTH_REQUESTED) { |
| 76 auth_controller->ResetAuth(net::AuthCredentials( | 76 auth_controller->ResetAuth(net::AuthCredentials( |
| 77 base::ASCIIToUTF16("user"), base::ASCIIToUTF16("pass"))); | 77 base::ASCIIToUTF16("user"), base::ASCIIToUTF16("pass"))); |
| 78 result = socket.RestartWithAuth(callback.callback()); | 78 result = socket.RestartWithAuth(callback.callback()); |
| 79 result = callback.GetResult(result); | 79 result = callback.GetResult(result); |
| 80 } | 80 } |
| 81 | 81 |
| 82 return 0; | 82 return 0; |
| 83 } | 83 } |
| OLD | NEW |