Skip to content

Commit 3737d35

Browse files
fuzz: Terminate immediately if a fuzzing harness ever tries to perform a DNS lookup (belts and suspenders)
1 parent eb4df9a commit 3737d35

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/test/fuzz/fuzz.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <cstdint>
1414
#include <exception>
1515
#include <memory>
16+
#include <string>
1617
#include <unistd.h>
1718
#include <vector>
1819

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

41+
// Terminate immediately if a fuzzing harness ever tries to perform a DNS lookup.
42+
g_dns_lookup = [](const std::string& name, bool allow_lookup) {
43+
if (allow_lookup) {
44+
std::terminate();
45+
}
46+
return WrappedGetAddrInfo(name, false);
47+
};
48+
4049
bool should_abort{false};
4150
if (std::getenv("PRINT_ALL_FUZZ_TARGETS_AND_ABORT")) {
4251
for (const auto& t : FuzzTargets()) {

0 commit comments

Comments
 (0)