aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz/fuzz.cpp
diff options
context:
space:
mode:
authorVasil Dimov <vd@FreeBSD.org>2024-05-30 13:38:26 +0200
committerVasil Dimov <vd@FreeBSD.org>2024-06-14 14:23:50 +0200
commit1245d1388b003c46092937def7041917aecec8de (patch)
tree8bb7b3137483cd1a9bf0f3b24dbc547cb4bf0a1c /src/test/fuzz/fuzz.cpp
parent0b94fb87206616e475566c3667cbaad0e9faa5b0 (diff)
downloadbitcoin-1245d1388b003c46092937def7041917aecec8de.tar.xz
netbase: extend CreateSock() to support creating arbitrary sockets
Allow the callers of `CreateSock()` to pass all 3 arguments to the `socket(2)` syscall. This makes it possible to create sockets of any domain/type/protocol.
Diffstat (limited to 'src/test/fuzz/fuzz.cpp')
-rw-r--r--src/test/fuzz/fuzz.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/test/fuzz/fuzz.cpp b/src/test/fuzz/fuzz.cpp
index 9a54a44bd3..c1c9945a04 100644
--- a/src/test/fuzz/fuzz.cpp
+++ b/src/test/fuzz/fuzz.cpp
@@ -101,8 +101,9 @@ void ResetCoverageCounters() {}
void initialize()
{
- // Terminate immediately if a fuzzing harness ever tries to create a TCP socket.
- CreateSock = [](const sa_family_t&) -> std::unique_ptr<Sock> { std::terminate(); };
+ // Terminate immediately if a fuzzing harness ever tries to create a socket.
+ // Individual tests can override this by pointing CreateSock to a mocked alternative.
+ CreateSock = [](int, int, int) -> std::unique_ptr<Sock> { std::terminate(); };
// Terminate immediately if a fuzzing harness ever tries to perform a DNS lookup.
g_dns_lookup = [](const std::string& name, bool allow_lookup) {