fuzz: Terminate immediately if a fuzzing harness ever tries to perform a DNS lookup (belts and suspenders)

This commit is contained in:
practicalswift 2021-05-21 19:43:15 +00:00
parent eb4df9a628
commit 3737d35fee

View File

@ -13,6 +13,7 @@
#include <cstdint>
#include <exception>
#include <memory>
#include <string>
#include <unistd.h>
#include <vector>
@ -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()) {