17#include "proto_fuzzer/allocation_fault_injection.h"
22#if defined(PROTO_FUZZER_OBSERVE_STATE)
42 const std::uint8_t* data2, std::size_t size2, std::uint8_t* out,
43 std::size_t max_out_size,
unsigned int seed);
52#if defined(PROTO_FUZZER_OBSERVE_STATE)
58void ProbeMutationEntrypoints() {
59 static const bool mutation_entrypoints_probed = [] {
60 constexpr std::size_t kBufferSize = 1024;
61 constexpr unsigned int kFirstSeed = 0x4355524cU;
62 constexpr unsigned int kSecondSeed = 0x46555a5aU;
64 std::array<std::uint8_t, kBufferSize> first = {};
65 std::array<std::uint8_t, kBufferSize> second = {};
66 std::array<std::uint8_t, kBufferSize> child = {};
70 child.data(), child.size(), kFirstSeed);
71 const volatile std::size_t result_sizes[] = {first_size, second_size, child_size};
75 (void)mutation_entrypoints_probed;
81namespace proto_fuzzer {
92 allocation_fault_injection::Reset();
110 std::size_t size2, std::uint8_t* out, std::size_t max_out_size,
112 allocation_fault_injection::Reset();
116 return traits.
custom_crossover(data1, size1, data2, size2, out, max_out_size, seed);
125 allocation_fault_injection::Reset();
126#if defined(PROTO_FUZZER_OBSERVE_STATE)
127 ProbeMutationEntrypoints();
132 curl::fuzzer::proto::Scenario scenario;
138 allocation_fault_injection::Configure(scenario.fail_allocations().data(),
139 static_cast<std::size_t
>(scenario.fail_allocations_size()));
140 allocation_fault_injection::Arm();
142 allocation_fault_injection::Reset();
144 scenario.resolver_mode() == curl::fuzzer::proto::RESOLVER_MODE_GLOBAL_LIFECYCLE) {
145 curl_global_cleanup();
146 if (!allocation_fault_injection::ReinitializeCurl()) {
147 std::fputs(
"warning: libcurl reinitialization failed\n", stderr);
148 (void)curl_global_init(CURL_GLOBAL_ALL);
Own the proto runtime's one curl global initialization.
Process-wide libcurl initialization and final cleanup.
std::size_t LLVMFuzzerCustomCrossOver(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)
Invoke this target's libFuzzer crossover from coverage-only corpus replay.
std::size_t ProtoFuzzerCustomMutator(std::uint8_t *data, std::size_t size, std::size_t max_size, unsigned int seed, const ProfileFuzzerTraits &traits)
Mutate one serialized generated profile message.
std::size_t LLVMFuzzerCustomMutator(std::uint8_t *data, std::size_t size, std::size_t max_size, unsigned int seed)
Invoke this target's libFuzzer mutator from coverage-only corpus replay.
int ProtoFuzzerTestOneInput(const std::uint8_t *data, std::size_t size, const ProfileFuzzerTraits &traits)
Load and execute one generated-profile input under its fixed target lane.
std::size_t ProtoFuzzerCustomCrossOver(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, const ProfileFuzzerTraits &traits)
Cross two serialized generated profile messages of the same concrete type.
Shared byte-to-protobuf dispatch for the policy-split fuzzers.
int RunScenario(const curl::fuzzer::proto::Scenario &scenario, ScenarioRunMode mode)
Execute one scenario under a complete target behaviour.
Orchestrates a single fuzz iteration from a Scenario proto through to a completed curl transfer.
Ordinary runtime binding for one generated protobuf profile.
CustomCrossOver custom_crossover
Typed crossover callback.
CustomMutator custom_mutator
Typed mutation callback.
TargetProfile profile
Runtime policy permanently associated with all callbacks.
MutationProbe probe_mutation_helpers
Timing-profile probe, or nullptr for ordinary profiles.
InputLoader load_input
Typed parse-and-lower callback.
void NormalizeScenarioForExecution(curl::fuzzer::proto::Scenario *scenario)
Apply execution-only allocation-failure safety rules.
Mutation policies that keep each proto fuzzer in one intentional performance and protocol lane.
constexpr ScenarioRunMode RunModeFor(TargetProfile profile)
Derive runtime behaviour from the compiled target identity.
@ kResolver
Exercise localhost lookup and structured CURLOPT_RESOLVE host-cache work.