Skip to content

Commit cc70886

Browse files
MarcoFalkePastaPastaPasta
authored andcommitted
Merge 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
1 parent f3bc953 commit cc70886

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
@@ -8,6 +8,7 @@
88
#include <util/check.h>
99

1010
#include <cstdint>
11+
#include <string>
1112
#include <unistd.h>
1213
#include <vector>
1314

@@ -29,6 +30,14 @@ static TypeTestOneInput* g_test_one_input{nullptr};
2930

3031
void initialize()
3132
{
33+
// Terminate immediately if a fuzzing harness ever tries to perform a DNS lookup.
34+
g_dns_lookup = [](const std::string& name, bool allow_lookup) {
35+
if (allow_lookup) {
36+
std::terminate();
37+
}
38+
return WrappedGetAddrInfo(name, false);
39+
};
40+
3241
if (std::getenv("PRINT_ALL_FUZZ_TARGETS_AND_ABORT")) {
3342
for (const auto& t : FuzzTargets()) {
3443
if (std::get<2>(t.second)) continue;

0 commit comments

Comments
 (0)