Skip to content

Commit

Permalink
fuzz: Terminate immediately if a fuzzing harness ever tries to perfor…
Browse files Browse the repository at this point in the history
…m a DNS lookup (belts and suspenders)
  • Loading branch information
practicalswift committed May 21, 2021
1 parent eb4df9a commit 3737d35
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/test/fuzz/fuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <cstdint>
#include <exception>
#include <memory>
#include <string>
#include <unistd.h>
#include <vector>

Expand All @@ -37,6 +38,14 @@ void initialize()
// Terminate immediately if a fuzzing harness ever tries to create a TCP socket.
CreateSock = [](const CService&) -> std::unique_ptr<Sock> { std::terminate(); };

// Terminate immediately if a fuzzing harness ever tries to perform a DNS lookup.
g_dns_lookup = [](const std::string& name, bool allow_lookup) {
if (allow_lookup) {
std::terminate();
}
return WrappedGetAddrInfo(name, false);
};

bool should_abort{false};
if (std::getenv("PRINT_ALL_FUZZ_TARGETS_AND_ABORT")) {
for (const auto& t : FuzzTargets()) {
Expand Down

0 comments on commit 3737d35

Please sign in to comment.