curl-fuzzer C++ reference
Loading...
Searching...
No Matches
proto_fuzzer::BoundedAnonymousInputFile Class Reference

A reusable anonymous regular file whose descriptor remains reachable as a pathname. More...

#include <bounded_anonymous_input_file.h>

Public Member Functions

 BoundedAnonymousInputFile (std::size_t max_bytes)
 Construct a lazy owner.
 ~BoundedAnonymousInputFile ()
 Close the anonymous file, invalidating the procfs pathname.
bool Write (const std::uint8_t *data, std::size_t size)
 Replace the complete file contents with one bounded byte string.
const char * path () const
 Return the stable procfs pathname after a successful Write.

Detailed Description

A reusable anonymous regular file whose descriptor remains reachable as a pathname.

libcurl and its TLS backends expose several parsers only through filename options; /proc/self/fd lets fuzz-controlled bytes reach those APIs without accepting a mutation-controlled filesystem path.

Definition at line 24 of file bounded_anonymous_input_file.h.

Constructor & Destructor Documentation

◆ BoundedAnonymousInputFile()

proto_fuzzer::BoundedAnonymousInputFile::BoundedAnonymousInputFile ( std::size_t max_bytes)
explicit

Construct a lazy owner.

No file is opened until Write succeeds far enough to need one, keeping ordinary fuzz iterations free of filesystem work.

Parameters
max_bytesLargest input this owner will expose.

Definition at line 23 of file bounded_anonymous_input_file.cc.

Member Function Documentation

◆ path()

const char * proto_fuzzer::BoundedAnonymousInputFile::path ( ) const

Return the stable procfs pathname after a successful Write.

Returns
NUL-terminated path, or nullptr when no complete input is ready.

Definition at line 89 of file bounded_anonymous_input_file.cc.

◆ Write()

bool proto_fuzzer::BoundedAnonymousInputFile::Write ( const std::uint8_t * data,
std::size_t size )

Replace the complete file contents with one bounded byte string.

A failed or oversized write invalidates path() so a previous iteration's bytes can never be consumed accidentally.

Parameters
dataBytes to write; may be null only when size is zero.
sizeNumber of bytes to expose.
Returns
True when the complete input is ready for a filename API.

Definition at line 60 of file bounded_anonymous_input_file.cc.


The documentation for this class was generated from the following files: