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

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

Issue 2250263003: Move FuzzedDataProvider to //base and expose to blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ... also remove PLATFORM_EXPORT Created 4 years, 4 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/socks5_client_socket_fuzzer.cc ('k') | net/udp/fuzzed_datagram_client_socket.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/test/fuzzed_data_provider.h"
11 #include "net/base/address_list.h" 12 #include "net/base/address_list.h"
12 #include "net/base/fuzzed_data_provider.h"
13 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "net/base/test_completion_callback.h" 14 #include "net/base/test_completion_callback.h"
15 #include "net/dns/host_resolver.h" 15 #include "net/dns/host_resolver.h"
16 #include "net/dns/mock_host_resolver.h" 16 #include "net/dns/mock_host_resolver.h"
17 #include "net/log/test_net_log.h" 17 #include "net/log/test_net_log.h"
18 #include "net/socket/client_socket_handle.h" 18 #include "net/socket/client_socket_handle.h"
19 #include "net/socket/fuzzed_socket.h" 19 #include "net/socket/fuzzed_socket.h"
20 #include "net/socket/socks_client_socket.h" 20 #include "net/socket/socks_client_socket.h"
21 21
22 // Fuzzer for SocksClientSocket. Only covers the SOCKS4 handshake. 22 // Fuzzer for SocksClientSocket. Only covers the SOCKS4 handshake.
23 // 23 //
24 // |data| is used to create a FuzzedSocket to fuzz reads and writes, see that 24 // |data| is used to create a FuzzedSocket to fuzz reads and writes, see that
25 // class for details. 25 // class for details.
26 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 26 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
27 // Use a test NetLog, to exercise logging code. 27 // Use a test NetLog, to exercise logging code.
28 net::TestNetLog test_net_log; 28 net::TestNetLog test_net_log;
29 29
30 net::FuzzedDataProvider data_provider(data, size); 30 base::FuzzedDataProvider data_provider(data, size);
31 31
32 // Determine if the DNS lookup returns synchronously or asynchronously, 32 // Determine if the DNS lookup returns synchronously or asynchronously,
33 // succeeds or fails, and returns an IPv4 or IPv6 address. 33 // succeeds or fails, and returns an IPv4 or IPv6 address.
34 net::MockHostResolver mock_host_resolver; 34 net::MockHostResolver mock_host_resolver;
35 scoped_refptr<net::RuleBasedHostResolverProc> rules( 35 scoped_refptr<net::RuleBasedHostResolverProc> rules(
36 new net::RuleBasedHostResolverProc(nullptr)); 36 new net::RuleBasedHostResolverProc(nullptr));
37 mock_host_resolver.set_synchronous_mode(data_provider.ConsumeBool()); 37 mock_host_resolver.set_synchronous_mode(data_provider.ConsumeBool());
38 switch (data_provider.ConsumeInt32InRange(0, 2)) { 38 switch (data_provider.ConsumeInt32InRange(0, 2)) {
39 case 0: 39 case 0:
40 rules->AddRule("*", "127.0.0.1"); 40 rules->AddRule("*", "127.0.0.1");
(...skipping 16 matching lines...) Expand all
57 new net::ClientSocketHandle()); 57 new net::ClientSocketHandle());
58 socket_handle->SetSocket(std::move(fuzzed_socket)); 58 socket_handle->SetSocket(std::move(fuzzed_socket));
59 59
60 net::HostResolver::RequestInfo request_info(net::HostPortPair("foo", 80)); 60 net::HostResolver::RequestInfo request_info(net::HostPortPair("foo", 80));
61 net::SOCKSClientSocket socket(std::move(socket_handle), request_info, 61 net::SOCKSClientSocket socket(std::move(socket_handle), request_info,
62 net::DEFAULT_PRIORITY, &mock_host_resolver); 62 net::DEFAULT_PRIORITY, &mock_host_resolver);
63 int result = socket.Connect(callback.callback()); 63 int result = socket.Connect(callback.callback());
64 callback.GetResult(result); 64 callback.GetResult(result);
65 return 0; 65 return 0;
66 } 66 }
OLDNEW
« no previous file with comments | « net/socket/socks5_client_socket_fuzzer.cc ('k') | net/udp/fuzzed_datagram_client_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698