diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2021-05-21 19:43:15 +0000 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2021-05-21 19:41:43 +0000 |
commit | 3737d35fee283968f12e0772aa27aee4981fce41 (patch) | |
tree | 37a93cd21cb1b8ea6ef55964c00c4052a7717754 /src/test/fuzz/fuzz.cpp | |
parent | eb4df9a628bdcdd1333c7fa4fb23c73df9642902 (diff) | |
download | bitcoin-3737d35fee283968f12e0772aa27aee4981fce41.tar.xz |
fuzz: Terminate immediately if a fuzzing harness ever tries to perform a DNS lookup (belts and suspenders)
Diffstat (limited to 'src/test/fuzz/fuzz.cpp')
-rw-r--r-- | src/test/fuzz/fuzz.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/test/fuzz/fuzz.cpp b/src/test/fuzz/fuzz.cpp index 631c861bb6..a33297e0ed 100644 --- a/src/test/fuzz/fuzz.cpp +++ b/src/test/fuzz/fuzz.cpp @@ -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()) { |