11#ifndef PROTO_FUZZER_REQUEST_DATA_H_
12#define PROTO_FUZZER_REQUEST_DATA_H_
21#include "curl_fuzzer.pb.h"
25namespace proto_fuzzer {
44 std::size_t
Read(
char* buffer, std::size_t capacity);
46 int Seek(curl_off_t requested_offset,
int origin);
52 std::size_t
offset()
const;
61 friend class ScenarioRequestData;
65 static std::size_t ReadCallback(
char* buffer, std::size_t size, std::size_t nitems,
void* userdata);
67 static int SeekCallback(
void* userdata, curl_off_t
offset,
int origin);
69 std::string_view data_;
70 std::array<std::size_t, scenario_limits::kMaxUploadReadSteps> read_sizes_;
71 std::size_t read_step_count_;
72 std::size_t total_size_;
73 std::size_t max_read_size_;
75 std::size_t next_read_size_;
76 std::size_t seek_calls_;
77 curl::fuzzer::proto::UploadTerminal terminal_;
78 curl::fuzzer::proto::UploadSeekResult seek_result_;
80 void* before_read_userdata_;
114 ScenarioRequestData(CURL* easy,
const curl::fuzzer::proto::Scenario& scenario,
bool apply_resolve_entries =
false);
118 bool apply_resolve_entries =
false) =
delete;
120 bool apply_resolve_entries =
false) =
delete;
147 bool upload_callbacks_installed_;
148 bool resolve_entries_ready_;
ScenarioRequestData(CURL *easy, curl::fuzzer::proto::Scenario &&scenario, bool apply_resolve_entries=false)=delete
A temporary Scenario cannot outlive the upload view retained for curl.
~ScenarioRequestData()
Detach pointer options/callbacks while the easy handle is valid, then release request allocations.
const RequestBuildStats & stats() const
Return resource counts after caps and allocation failures were applied, without exposing or transferr...
const UploadScriptState & upload_state() const
Return the callback state retained for the complete drive.
bool resolve_entries_ready() const
Return whether resolver-only slist construction installed its mandatory final loopback mapping.
void SetBeforeUploadReadCallback(UploadScriptState::BeforeReadCallback callback, void *userdata)
Arrange protocol-specific work immediately before every upload read.
bool upload_callbacks_installed() const
Return whether this scenario needed raw upload callbacks.
ScenarioRequestData(CURL *easy, const curl::fuzzer::proto::Scenario &scenario, bool apply_resolve_entries=false)
Construct and apply the protocol-specific pointer-valued fields in scenario to easy.
Cursor and policy behind the request read/seek callbacks.
std::size_t Read(char *buffer, std::size_t capacity)
Copy the next bounded chunk and advance the cursor, using either the explicit payload or the allocati...
int Seek(curl_off_t requested_offset, int origin)
Apply the configured seek outcome and, for OK, move the bounded cursor.
CURLcode InstallAsMimePart(curl_mimepart *part)
Install the same bounded read/seek cursor behind a public MIME callback part.
std::size_t read_step_count() const
std::size_t offset() const
std::size_t seek_calls() const
UploadScriptState(const curl::fuzzer::proto::Scenario &scenario)
Borrow and cap a scripted upload source before libcurl receives a userdata pointer.
UploadScriptState(curl::fuzzer::proto::Scenario &&scenario)=delete
A temporary Scenario cannot satisfy the borrowed payload's lifetime.
void(*)(void *) BeforeReadCallback
C-compatible hook invoked immediately before each read result is chosen.
std::size_t data_size() const
Common ownership types for independently cleaned-up curl handles.
std::unique_ptr< curl_slist, CurlSlistDeleter > CurlSlistPtr
Unique ownership of a caller-owned curl_slist.
std::unique_ptr< curl_mime, CurlMimeDeleter > CurlMimePtr
Unique ownership of a caller-owned curl_mime tree.
Shared complexity limits for structured scenarios.
Counts the resources that survived allocation and runtime budgets.
std::size_t generated_mime_bytes
Materialized bytes supplied by compact generated MIME sources.
std::size_t telnet_options
Number of CURLOPT_TELNETOPTIONS entries retained.
std::size_t mime_parts
Number of top-level and nested curl_mimepart objects constructed.
std::size_t request_headers
Number of top-level CURLOPT_HTTPHEADER entries retained.
std::size_t mime_callback_parts
Number of top-level parts backed by Scenario.upload callbacks.
std::size_t mime_headers
Number of per-part header entries transferred to curl MIME ownership.
std::size_t mail_rcpt
Number of SMTP recipients retained in the CURLOPT_MAIL_RCPT list.
std::size_t resolve_entries
Number of fuzzed CURLOPT_RESOLVE entries retained before the fixed loopback mapping was appended.