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/url_request/url_request.h" | |
| 6 | |
| 7 #include <stddef.h> | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <memory> | |
| 11 | |
| 12 #include "base/run_loop.h" | |
| 13 #include "net/base/fuzzed_data_provider.h" | |
| 14 #include "net/base/request_priority.h" | |
| 15 #include "net/socket/fuzzed_socket_factory.h" | |
| 16 #include "net/url_request/url_request.h" | |
| 17 #include "net/url_request/url_request_context.h" | |
| 18 #include "net/url_request/url_request_test_util.h" | |
| 19 #include "url/gurl.h" | |
| 20 | |
| 21 // Integration fuzzer for URLRequest's handling of HTTP requests. Can follow | |
| 22 // redirects, both on the same server (using a new socket or the old one) and | |
| 23 // across servers. | |
| 24 // TODO(mmenke): Add support for testing HTTPS, FTP, auth, proxies, uploading, | |
| 25 // cancelation, deferring reads / redirects, using preconnected sockets, SPDY, | |
| 26 // QUIC, DNS failures (they all currently resolve to localhost), IPv6 DNS | |
| 27 // results, URLs with IPs instead of hostnames (v4 and v6), etc. | |
| 28 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | |
| 29 net::FuzzedDataProvider data_provider(data, size); | |
| 30 net::TestURLRequestContext url_request_context(true); | |
| 31 net::FuzzedSocketFactory fuzzed_socket_factory(&data_provider); | |
| 32 url_request_context.set_client_socket_factory(&fuzzed_socket_factory); | |
| 33 url_request_context.Init(); | |
| 34 | |
| 35 net::TestDelegate delegate; | |
| 36 | |
| 37 std::unique_ptr<net::URLRequest> url_request( | |
| 38 url_request_context.CreateRequest(GURL("http://foo/"), | |
| 39 net::DEFAULT_PRIORITY, &delegate)); | |
| 40 url_request->Start(); | |
| 41 base::RunLoop().Run(); | |
|
eroman
2016/04/28 01:32:36
Could you add a comment explaining that TestDelega
mmenke
2016/04/28 16:01:38
Done.
| |
| 42 return 0; | |
| 43 } | |
| OLD | NEW |