diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2021-05-20 19:01:46 +0000 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2021-05-20 19:02:37 +0000 |
commit | 393992b049d3bcf0b2a3439be128d13d6567f0b1 (patch) | |
tree | 55cdf7a73ccd5df556dccda6a51b37cb67c7635b /src | |
parent | 0ab6ff5e375900906fdf6a2834fedcc76d0e031c (diff) |
fuzz: Terminate immediately if a fuzzing harness ever tries to create a TCP socket (belt and suspenders)
Diffstat (limited to 'src')
-rw-r--r-- | src/test/fuzz/fuzz.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/test/fuzz/fuzz.cpp b/src/test/fuzz/fuzz.cpp index 0d8d960d56..631c861bb6 100644 --- a/src/test/fuzz/fuzz.cpp +++ b/src/test/fuzz/fuzz.cpp @@ -4,10 +4,15 @@ #include <test/fuzz/fuzz.h> +#include <netaddress.h> +#include <netbase.h> #include <test/util/setup_common.h> #include <util/check.h> +#include <util/sock.h> #include <cstdint> +#include <exception> +#include <memory> #include <unistd.h> #include <vector> @@ -29,6 +34,9 @@ static TypeTestOneInput* g_test_one_input{nullptr}; void initialize() { + // Terminate immediately if a fuzzing harness ever tries to create a TCP socket. + CreateSock = [](const CService&) -> std::unique_ptr<Sock> { std::terminate(); }; + bool should_abort{false}; if (std::getenv("PRINT_ALL_FUZZ_TARGETS_AND_ABORT")) { for (const auto& t : FuzzTargets()) { |