Skip to content

Commit 6c242da

Browse files
MarcoFalkePastaPastaPasta
authored andcommitted
Merge 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
1 parent 26ff28a commit 6c242da

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,11 +4,16 @@
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>
1114
#include <string>
15+
#include <exception>
16+
#include <memory>
1217
#include <unistd.h>
1318
#include <vector>
1419

@@ -30,6 +35,9 @@ static TypeTestOneInput* g_test_one_input{nullptr};
3035

3136
void initialize()
3237
{
38+
// Terminate immediately if a fuzzing harness ever tries to create a TCP socket.
39+
CreateSock = [](const CService&) -> std::unique_ptr<Sock> { std::terminate(); };
40+
3341
// Terminate immediately if a fuzzing harness ever tries to perform a DNS lookup.
3442
g_dns_lookup = [](const std::string& name, bool allow_lookup) {
3543
if (allow_lookup) {

0 commit comments

Comments
 (0)