Skip to content

Commit ac5f7f4

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#21936: fuzz: Terminate immediately if a fuzzing harness tries to create a TCP socket (belt and suspenders)
393992b fuzz: Terminate immediately if a fuzzing harness ever tries to create a TCP socket (belt and suspenders) (practicalswift) Pull request description: Terminate immediately if a fuzzing harness ever to create a TCP socket (belt and suspenders). Obviously this _should_ never happen, but if it _does_ happen we want immediate termination instead of a TCP socket :) ACKs for top commit: MarcoFalke: ACK 393992b Tree-SHA512: 5bbff1f7e9a58b3eae24f742b7daf3fc870424c985f29bed5931e47a708d9c0984bfd8762f43658cffa9c69d32f86d56deb48bc7e43821e3398052174b6a160e
2 parents 1cc38d3 + 393992b commit ac5f7f4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/test/fuzz/fuzz.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44

55
#include <test/fuzz/fuzz.h>
66

7+
#include <netaddress.h>
8+
#include <netbase.h>
79
#include <test/util/setup_common.h>
810
#include <util/check.h>
11+
#include <util/sock.h>
912

1013
#include <cstdint>
14+
#include <exception>
15+
#include <memory>
1116
#include <unistd.h>
1217
#include <vector>
1318

@@ -29,6 +34,9 @@ static TypeTestOneInput* g_test_one_input{nullptr};
2934

3035
void initialize()
3136
{
37+
// Terminate immediately if a fuzzing harness ever tries to create a TCP socket.
38+
CreateSock = [](const CService&) -> std::unique_ptr<Sock> { std::terminate(); };
39+
3240
bool should_abort{false};
3341
if (std::getenv("PRINT_ALL_FUZZ_TARGETS_AND_ABORT")) {
3442
for (const auto& t : FuzzTargets()) {

0 commit comments

Comments
 (0)