Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 "net/socket/socks_client_socket.h" | |
| 6 | |
| 7 #include <stddef.h> | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include "base/logging.h" | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/message_loop/message_loop.h" | |
| 13 #include "net/base/address_list.h" | |
| 14 #include "net/base/net_errors.h" | |
| 15 #include "net/base/test_completion_callback.h" | |
| 16 #include "net/dns/host_resolver.h" | |
| 17 #include "net/dns/mock_host_resolver.h" | |
| 18 #include "net/log/test_net_log.h" | |
| 19 #include "net/socket/client_socket_handle.h" | |
| 20 #include "net/socket/fuzzed_socket.h" | |
| 21 | |
| 22 // Fuzzer for SocksClientSocket. Only covers the SOCKS4 handshake. | |
| 23 // | |
| 24 // |data| is used to create a FuzzedSocket to fuzz reads and writes, see that | |
| 25 // class for details. | |
| 26 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | |
| 27 // Needed for thread checks and waits. | |
| 28 base::MessageLoopForIO message_loop; | |
| 29 | |
| 30 // Use a test NetLog, to exercise logging code. | |
| 31 net::BoundTestNetLog bound_test_net_log; | |
| 32 | |
| 33 net::TestCompletionCallback callback; | |
| 34 scoped_ptr<net::FuzzedSocket> fuzzed_socket( | |
| 35 new net::FuzzedSocket(data, size, bound_test_net_log.bound())); | |
| 36 CHECK_EQ(net::OK, fuzzed_socket->Connect(callback.callback())); | |
| 37 | |
| 38 scoped_ptr<net::ClientSocketHandle> socket_handle( | |
| 39 new net::ClientSocketHandle()); | |
| 40 socket_handle->SetSocket(std::move(fuzzed_socket)); | |
| 41 | |
| 42 net::HostResolver::RequestInfo request_info(net::HostPortPair("foo", 80)); | |
| 43 net::MockHostResolver mock_host_resolver; | |
|
eroman
2016/04/14 17:56:28
It would be interesting to fuzz the host resolutio
mmenke
2016/04/14 19:01:51
Done. I'm returning a fixed address in each case
| |
| 44 net::SOCKSClientSocket socket(std::move(socket_handle), request_info, | |
| 45 net::DEFAULT_PRIORITY, &mock_host_resolver); | |
| 46 int result = socket.Connect(callback.callback()); | |
| 47 callback.GetResult(result); | |
| 48 return 0; | |
| 49 } | |
| OLD | NEW |