Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: net/socket/socks5_client_socket_fuzzer.cc

Issue 1854813004: Add SOCKS4 and SOCKS5 fuzzers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/socket/fuzzed_socket.cc ('k') | net/socket/socks_client_socket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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/socks5_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/log/test_net_log.h"
17 #include "net/socket/client_socket_handle.h"
18 #include "net/socket/fuzzed_socket.h"
19
20 // Fuzzer for Socks5ClientSocket. Only covers the SOCKS5 greeet and
21 // handshake.
22 //
23 // |data| is used to create a FuzzedSocket to fuzz reads and writes, see that
24 // class for details.
25 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
26 // Needed for thread checks and waits.
27 base::MessageLoopForIO message_loop;
28
29 // Use a test NetLog, to exercise logging code.
30 net::BoundTestNetLog bound_test_net_log;
31
32 net::TestCompletionCallback callback;
33 scoped_ptr<net::FuzzedSocket> fuzzed_socket(
34 new net::FuzzedSocket(data, size, bound_test_net_log.bound()));
35 CHECK_EQ(net::OK, fuzzed_socket->Connect(callback.callback()));
36
37 scoped_ptr<net::ClientSocketHandle> socket_handle(
38 new net::ClientSocketHandle());
39 socket_handle->SetSocket(std::move(fuzzed_socket));
40
41 net::HostResolver::RequestInfo request_info(net::HostPortPair("foo", 80));
42 net::SOCKS5ClientSocket socket(std::move(socket_handle), request_info);
43 int result = socket.Connect(callback.callback());
44 callback.GetResult(result);
45 return 0;
46 }
OLDNEW
« no previous file with comments | « net/socket/fuzzed_socket.cc ('k') | net/socket/socks_client_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698