aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-06-07 09:03:40 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-06-07 09:03:44 +0200
commit912cb594901b1a5dd99aa4c00be34ae36512bc57 (patch)
treeda416303718462096655a454016e153e3056019a /src
parent791f985a60726febca3053453c2710407529fd0a (diff)
parent3737d35fee283968f12e0772aa27aee4981fce41 (diff)
Merge bitcoin/bitcoin#21795: fuzz: Terminate immediately if a fuzzing harness tries to perform a DNS lookup (belt and suspenders)
3737d35fee283968f12e0772aa27aee4981fce41 fuzz: Terminate immediately if a fuzzing harness ever tries to perform a DNS lookup (belts and suspenders) (practicalswift) Pull request description: Terminate immediately if a fuzzing harness tries to perform a DNS lookup (belt and suspenders). Obviously this _should_ never happen, but if it _does_ happen we want immediate termination instead of a DNS lookup :) ACKs for top commit: MarcoFalke: review ACK 3737d35fee283968f12e0772aa27aee4981fce41 Tree-SHA512: 51cd2d32def7f9f052e02f99c354656af1f807cc9fdf592ab765e620bfe660f1ed26e0484763f94aba650424b44959eafaf352bfd0f81aa273e350510e97356e
Diffstat (limited to 'src')
-rw-r--r--src/test/fuzz/fuzz.cpp9
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()) {