|
curl-fuzzer C++ reference
|
Cursor and policy behind the request read/seek callbacks. More...
#include <request_data.h>
Public Types | |
| using | BeforeReadCallback = void (*)(void*) |
| C-compatible hook invoked immediately before each read result is chosen. | |
Public Member Functions | |
| 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. | |
| 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 allocation-free fallback. | |
| int | Seek (curl_off_t requested_offset, int origin) |
| Apply the configured seek outcome and, for OK, move the bounded cursor. | |
| std::size_t | data_size () const |
| std::size_t | read_step_count () const |
| std::size_t | offset () const |
| std::size_t | seek_calls () const |
| bool | scripted () const |
| CURLcode | InstallAsMimePart (curl_mimepart *part) |
| Install the same bounded read/seek cursor behind a public MIME callback part. | |
Cursor and policy behind the request read/seek callbacks.
Keeping it per RunScenario invocation avoids the file-static state that made nested or concurrent reproductions share an upload cursor, and gives retry paths a real rewindable source rather than stdin.
Definition at line 31 of file request_data.h.
| using proto_fuzzer::UploadScriptState::BeforeReadCallback = void (*)(void*) |
C-compatible hook invoked immediately before each read result is chosen.
TELNET uses it to drain replies while curl's synchronous protocol loop prevents the outer mock driver from running.
Definition at line 36 of file request_data.h.
|
explicit |
Borrow and cap a scripted upload source before libcurl receives a userdata pointer.
When Scenario.upload is absent, non-TELNET schemes synthesize the historical 16 KiB U stream without allocating it, while TELNET reports immediate EOF so merely selecting the protocol cannot inject unsolicited terminal input. Borrowing avoids duplicating every fuzzed body before curl can read it; scenario must remain alive and unmodified until this state is destroyed.
| scenario | Source and lifetime owner of callback bytes and outcomes. |
Definition at line 272 of file request_data.cc.
| std::size_t proto_fuzzer::UploadScriptState::data_size | ( | ) | const |
Definition at line 439 of file request_data.cc.
| CURLcode proto_fuzzer::UploadScriptState::InstallAsMimePart | ( | curl_mimepart * | part | ) |
Install the same bounded read/seek cursor behind a public MIME callback part.
curl retains this until the MIME root is freed, so ScenarioRequestData declares the root after the state and detaches it before either is released.
| part | MIME part owned by the caller's live root. |
Definition at line 458 of file request_data.cc.
| std::size_t proto_fuzzer::UploadScriptState::offset | ( | ) | const |
Definition at line 445 of file request_data.cc.
| std::size_t proto_fuzzer::UploadScriptState::Read | ( | char * | buffer, |
| std::size_t | capacity ) |
Copy the next bounded chunk and advance the cursor, using either the explicit payload or the allocation-free fallback.
Terminal outcomes are emitted only after all data is consumed so a mutation can independently control fragmentation and completion policy. Public so focused tests can validate callback semantics without relying on HTTP timing.
| buffer | Destination supplied by curl. |
| capacity | Writable bytes in buffer. |
Definition at line 327 of file request_data.cc.
| std::size_t proto_fuzzer::UploadScriptState::read_step_count | ( | ) | const |
Definition at line 442 of file request_data.cc.
| bool proto_fuzzer::UploadScriptState::scripted | ( | ) | const |
Definition at line 451 of file request_data.cc.
| int proto_fuzzer::UploadScriptState::Seek | ( | curl_off_t | requested_offset, |
| int | origin ) |
Apply the configured seek outcome and, for OK, move the bounded cursor.
Successful seeks restart the short-read sequence so retries replay the same callback fragmentation deterministically. Explicit range checks model only seeks curl can meaningfully request from a bounded memory source, avoiding signed overflow or a mutation wrapping into an in-bounds cursor.
| requested_offset | Offset interpreted relative to origin. |
| origin | One of SEEK_SET, SEEK_CUR, or SEEK_END. |
Definition at line 372 of file request_data.cc.
| std::size_t proto_fuzzer::UploadScriptState::seek_calls | ( | ) | const |
Definition at line 448 of file request_data.cc.