MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / FUZZ_TARGET

Function FUZZ_TARGET

src/test/fuzz/http_request.cpp:21–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19std::string_view RequestMethodString(HTTPRequestMethod m);
20
21FUZZ_TARGET(http_request)
22{
23 using http_bitcoin::HTTPRequest;
24 using http_bitcoin::MAX_HEADERS_SIZE;
25 using util::LineReader;
26
27 FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
28 const std::vector<std::byte> http_buffer{ConsumeRandomLengthByteVector<std::byte>(fuzzed_data_provider, 4096)};
29
30 HTTPRequest http_request;
31 LineReader reader(http_buffer, MAX_HEADERS_SIZE);
32 try {
33 if (!http_request.LoadControlData(reader)) return;
34 if (!http_request.LoadHeaders(reader)) return;
35 if (!http_request.LoadBody(reader)) return;
36 } catch (const std::runtime_error&) {
37 return;
38 }
39
40 const HTTPRequestMethod request_method = http_request.GetRequestMethod();
41 (void)RequestMethodString(request_method);
42 (void)http_request.GetURI();
43 (void)http_request.GetHeader("Host");
44 std::string header = fuzzed_data_provider.ConsumeRandomLengthString(16);
45 (void)http_request.GetHeader(header);
46 (void)http_request.WriteHeader(std::string(header), fuzzed_data_provider.ConsumeRandomLengthString(16));
47 (void)http_request.GetHeader(header);
48 const std::string body = http_request.ReadBody();
49 assert(body.empty());
50}

Callers

nothing calls this directly

Calls 13

RequestMethodStringFunction · 0.85
LoadControlDataMethod · 0.80
LoadHeadersMethod · 0.80
LoadBodyMethod · 0.80
GetRequestMethodMethod · 0.80
GetURIMethod · 0.80
WriteHeaderMethod · 0.80
ReadBodyMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45
GetHeaderMethod · 0.45

Tested by

no test coverage detected