curl-fuzzer C++ reference
Loading...
Searching...
No Matches
proto_fuzzer::ProfileFuzzerHooks< Traits > Class Template Reference

Bind all LPM operations for one process to one protobuf message type. More...

#include <profile_fuzzer.h>

Public Types

using Message = typename Traits::Message
 Concrete generated protobuf root for this target profile.
using RuntimeScenario = curl::fuzzer::proto::Scenario
 Shared internal Scenario consumed by the runtime.

Static Public Member Functions

static void EnsurePostProcessor ()
 Register the profile postprocessor before the first LPM operation.
static void NormalizeMessage (Message *message)
 Remove unknown wire data, normalize through the common runtime model, and lift back into the same generated profile type.
static std::size_t CustomMutator (std::uint8_t *data, std::size_t size, std::size_t max_size, unsigned int seed)
 Mutate a binary profile message and retain its exact type in LPM's cache.
static std::size_t CustomCrossOver (const std::uint8_t *data1, std::size_t size1, const std::uint8_t *data2, std::size_t size2, std::uint8_t *out, std::size_t max_out_size, unsigned int seed)
 Cross two binary profile messages using the same type as mutation/load.
static bool LoadAndLower (const std::uint8_t *data, std::size_t size, RuntimeScenario *runtime)
 Load one binary profile message and transfer it into owned runtime state.

Detailed Description

template<typename Traits>
class proto_fuzzer::ProfileFuzzerHooks< Traits >

Bind all LPM operations for one process to one protobuf message type.

Traits must provide:

  • using Message for the generated profile root;
  • static constexpr TargetProfile kProfile;
  • Lower(Message*, curl::fuzzer::proto::Scenario*); and
  • Lift(curl::fuzzer::proto::Scenario*, Message*); and
  • PruneConditionalEligibility(curl::fuzzer::proto::Scenario*, TargetProfile).

Lower and Lift transfer fields directly. They must not serialize, reparse, reflection-swap unlike message types, or retain pointers into the source. Keeping the same Message in mutation, crossover, and loading is required by LPM's process-wide last-mutation cache.

Definition at line 69 of file profile_fuzzer.h.

Member Function Documentation

◆ CustomCrossOver()

template<typename Traits>
std::size_t proto_fuzzer::ProfileFuzzerHooks< Traits >::CustomCrossOver ( const std::uint8_t * data1,
std::size_t size1,
const std::uint8_t * data2,
std::size_t size2,
std::uint8_t * out,
std::size_t max_out_size,
unsigned int seed )
inlinestatic

Cross two binary profile messages using the same type as mutation/load.

Parameters
data1Serialized first parent message.
size1Number of bytes in data1.
data2Serialized second parent message.
size2Number of bytes in data2.
outDestination buffer for the crossed message.
max_out_sizeCapacity of out.
seedDeterministic crossover seed supplied by libFuzzer.
Returns
Number of serialized bytes written to out.

Definition at line 122 of file profile_fuzzer.h.

◆ CustomMutator()

template<typename Traits>
std::size_t proto_fuzzer::ProfileFuzzerHooks< Traits >::CustomMutator ( std::uint8_t * data,
std::size_t size,
std::size_t max_size,
unsigned int seed )
inlinestatic

Mutate a binary profile message and retain its exact type in LPM's cache.

Parameters
dataSerialized profile message buffer to mutate in place.
sizeNumber of input bytes currently stored in data.
max_sizeCapacity of data available for the mutated message.
seedDeterministic mutation seed supplied by libFuzzer.
Returns
Number of serialized bytes in the mutated message.

Definition at line 107 of file profile_fuzzer.h.

◆ LoadAndLower()

template<typename Traits>
bool proto_fuzzer::ProfileFuzzerHooks< Traits >::LoadAndLower ( const std::uint8_t * data,
std::size_t size,
RuntimeScenario * runtime )
inlinestatic

Load one binary profile message and transfer it into owned runtime state.

This deliberately uses LPM's ordinary input unchanged. On a cache hit, the cached Message is the same concrete type used above; on a parse path, LPM invokes the registered postprocessor before this direct lowering.

Parameters
dataSerialized profile message bytes.
sizeNumber of bytes available at data.
runtimeDestination for the owned, lowered runtime Scenario.
Returns
Whether the input loaded and lowered successfully.

Definition at line 141 of file profile_fuzzer.h.

◆ NormalizeMessage()

template<typename Traits>
void proto_fuzzer::ProfileFuzzerHooks< Traits >::NormalizeMessage ( Message * message)
inlinestatic

Remove unknown wire data, normalize through the common runtime model, and lift back into the same generated profile type.

Parameters
messageGenerated profile message to normalize in place.

Definition at line 86 of file profile_fuzzer.h.


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