Skip to content

Commit 912cb59

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#21795: fuzz: Terminate immediately if a fuzzing harness tries to perform a DNS lookup (belt and suspenders)
3737d35 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 3737d35 Tree-SHA512: 51cd2d32def7f9f052e02f99c354656af1f807cc9fdf592ab765e620bfe660f1ed26e0484763f94aba650424b44959eafaf352bfd0f81aa273e350510e97356e
2 parents 791f985 + 3737d35 commit 912cb59

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)