Skip to content

Commit 393992b

Browse files
fuzz: Terminate immediately if a fuzzing harness ever tries to create a TCP socket (belt and suspenders)
1 parent 0ab6ff5 commit 393992b

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)