#include "src/libfuzzer/libfuzzer_macro.h"
#include <algorithm>
#include <memory>
#include <vector>
#include "src/binary_format.h"
#include "src/libfuzzer/libfuzzer_mutator.h"
#include "src/text_format.h"
namespace protobuf_mutator {
namespace libfuzzer {
namespace {
class InputReader { … };
class OutputWriter { … };
class TextInputReader : public InputReader { … };
class TextOutputWriter : public OutputWriter { … };
class BinaryInputReader : public InputReader { … };
class BinaryOutputWriter : public OutputWriter { … };
class LastMutationCache { … };
LastMutationCache* GetCache() { … }
Mutator* GetMutator() { … }
size_t GetMaxSize(const InputReader& input, const OutputWriter& output,
const protobuf::Message& message) { … }
size_t MutateMessage(unsigned int seed, const InputReader& input,
OutputWriter* output, protobuf::Message* message) { … }
size_t CrossOverMessages(unsigned int seed, const InputReader& input1,
const InputReader& input2, OutputWriter* output,
protobuf::Message* message1,
protobuf::Message* message2) { … }
size_t MutateTextMessage(uint8_t* data, size_t size, size_t max_size,
unsigned int seed, protobuf::Message* message) { … }
size_t CrossOverTextMessages(const uint8_t* data1, size_t size1,
const uint8_t* data2, size_t size2, uint8_t* out,
size_t max_out_size, unsigned int seed,
protobuf::Message* message1,
protobuf::Message* message2) { … }
size_t MutateBinaryMessage(uint8_t* data, size_t size, size_t max_size,
unsigned int seed, protobuf::Message* message) { … }
size_t CrossOverBinaryMessages(const uint8_t* data1, size_t size1,
const uint8_t* data2, size_t size2, uint8_t* out,
size_t max_out_size, unsigned int seed,
protobuf::Message* message1,
protobuf::Message* message2) { … }
}
size_t CustomProtoMutator(bool binary, uint8_t* data, size_t size,
size_t max_size, unsigned int seed,
protobuf::Message* input) { … }
size_t CustomProtoCrossOver(bool binary, const uint8_t* data1, size_t size1,
const uint8_t* data2, size_t size2, uint8_t* out,
size_t max_out_size, unsigned int seed,
protobuf::Message* input1,
protobuf::Message* input2) { … }
bool LoadProtoInput(bool binary, const uint8_t* data, size_t size,
protobuf::Message* input) { … }
void RegisterPostProcessor(
const protobuf::Descriptor* desc,
std::function<void(protobuf::Message* message, unsigned int seed)>
callback) { … }
}
}