22std::map<std::string_view, std::tuple<TypeTestOneInput, TypeInitialize, TypeHidden>>&
FuzzTargets()
24 static std::map<std::string_view, std::tuple<TypeTestOneInput, TypeInitialize, TypeHidden>> g_fuzz_targets;
25 return g_fuzz_targets;
30 const auto it_ins =
FuzzTargets().try_emplace(
name, std::move(target), std::move(
init), hidden);
49 bool should_abort{
false};
50 if (std::getenv(
"PRINT_ALL_FUZZ_TARGETS_AND_ABORT")) {
52 if (std::get<2>(t.second))
continue;
53 std::cout << t.first << std::endl;
57 if (
const char* out_path = std::getenv(
"WRITE_ALL_FUZZ_TARGETS_AND_ABORT")) {
58 std::cout <<
"Writing all fuzz target names to '" << out_path <<
"'." << std::endl;
61 if (std::get<2>(t.second))
continue;
62 out_stream << t.first << std::endl;
72 std::get<1>(it->second)();
75#if defined(PROVIDE_FUZZ_MAIN_FUNCTION)
76static bool read_stdin(std::vector<uint8_t>& data)
80 while ((length = read(STDIN_FILENO, buffer, 1024)) > 0) {
81 data.insert(data.end(), buffer, buffer + length);
91 test_one_input({data, size});
102#if defined(PROVIDE_FUZZ_MAIN_FUNCTION)
103int main(
int argc,
char** argv)
116 while (__AFL_LOOP(1000)) {
117 std::vector<uint8_t> buffer;
118 if (!read_stdin(buffer)) {
121 test_one_input(buffer);
124 std::vector<uint8_t> buffer;
125 if (!read_stdin(buffer)) {
128 test_one_input(buffer);
int main(int argc, char **argv)
#define Assert(val)
Identity function.
A combination of a network address (CNetAddr) and a (TCP) port.
const std::function< void(const std::string &)> G_TEST_LOG_FUN
This is connected to the logger.
std::map< std::string_view, std::tuple< TypeTestOneInput, TypeInitialize, TypeHidden > > & FuzzTargets()
void FuzzFrameworkRegisterTarget(std::string_view name, TypeTestOneInput target, TypeInitialize init, TypeHidden hidden)
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
int LLVMFuzzerInitialize(int *argc, char ***argv)
static TypeTestOneInput * g_test_one_input
std::function< void(FuzzBufferType)> TypeTestOneInput
std::function< void()> TypeInitialize
std::function< std::unique_ptr< Sock >(const CService &)> CreateSock
Socket factory.
std::vector< CNetAddr > WrappedGetAddrInfo(const std::string &name, bool allow_lookup)
Wrapper for getaddrinfo(3).
void fuzz_target(FuzzBufferType buffer, const std::string &LIMIT_TO_MESSAGE_TYPE)