| 19 | std::string_view RequestMethodString(HTTPRequestMethod m); |
| 20 | |
| 21 | FUZZ_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 | } |
nothing calls this directly
no test coverage detected