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

Side by Side Diff: net/http/http_stream_parser_fuzzer.cc

Issue 1917503002: URLRequest fuzzer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fuzz
Patch Set: Add missing include Created 4 years, 7 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
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 "net/http/http_stream_parser.h" 5 #include "net/http/http_stream_parser.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "net/base/fuzzed_data_provider.h"
18 #include "net/base/io_buffer.h" 19 #include "net/base/io_buffer.h"
19 #include "net/base/net_errors.h" 20 #include "net/base/net_errors.h"
20 #include "net/base/test_completion_callback.h" 21 #include "net/base/test_completion_callback.h"
21 #include "net/http/http_request_headers.h" 22 #include "net/http/http_request_headers.h"
22 #include "net/http/http_request_info.h" 23 #include "net/http/http_request_info.h"
23 #include "net/http/http_response_info.h" 24 #include "net/http/http_response_info.h"
24 #include "net/log/net_log.h" 25 #include "net/log/net_log.h"
25 #include "net/log/test_net_log.h" 26 #include "net/log/test_net_log.h"
26 #include "net/socket/client_socket_handle.h" 27 #include "net/socket/client_socket_handle.h"
27 #include "net/socket/fuzzed_socket.h" 28 #include "net/socket/fuzzed_socket.h"
28 #include "url/gurl.h" 29 #include "url/gurl.h"
29 30
30 // Fuzzer for HttpStreamParser. 31 // Fuzzer for HttpStreamParser.
31 // 32 //
32 // |data| is used to create a FuzzedSocket. 33 // |data| is used to create a FuzzedSocket.
33 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { 34 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
34 net::TestCompletionCallback callback; 35 net::TestCompletionCallback callback;
35 net::BoundTestNetLog bound_test_net_log; 36 net::BoundTestNetLog bound_test_net_log;
36 std::unique_ptr<net::FuzzedSocket> fuzzed_socket( 37 net::FuzzedDataProvider data_provider(data, size);
37 new net::FuzzedSocket(data, size, bound_test_net_log.bound())); 38 std::unique_ptr<net::FuzzedSocket> fuzzed_socket(new net::FuzzedSocket(
39 &data_provider, bound_test_net_log.bound().net_log()));
38 CHECK_EQ(net::OK, fuzzed_socket->Connect(callback.callback())); 40 CHECK_EQ(net::OK, fuzzed_socket->Connect(callback.callback()));
39 41
40 net::ClientSocketHandle socket_handle; 42 net::ClientSocketHandle socket_handle;
41 socket_handle.SetSocket(std::move(fuzzed_socket)); 43 socket_handle.SetSocket(std::move(fuzzed_socket));
42 44
43 net::HttpRequestInfo request_info; 45 net::HttpRequestInfo request_info;
44 request_info.method = "GET"; 46 request_info.method = "GET";
45 request_info.url = GURL("http://localhost/"); 47 request_info.url = GURL("http://localhost/");
46 48
47 scoped_refptr<net::GrowableIOBuffer> read_buffer(new net::GrowableIOBuffer()); 49 scoped_refptr<net::GrowableIOBuffer> read_buffer(new net::GrowableIOBuffer());
(...skipping 24 matching lines...) Expand all
72 74
73 // Releasing the pointer to IOBuffer immediately is more likely to lead to a 75 // Releasing the pointer to IOBuffer immediately is more likely to lead to a
74 // use-after-free. 76 // use-after-free.
75 io_buffer = nullptr; 77 io_buffer = nullptr;
76 if (callback.GetResult(result) <= 0) 78 if (callback.GetResult(result) <= 0)
77 break; 79 break;
78 } 80 }
79 81
80 return 0; 82 return 0;
81 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698