mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-04 17:00:52 +02:00
fuzz: Terminate immediately if a fuzzing harness ever tries to perform a DNS lookup (belts and suspenders)
This commit is contained in:
parent
eb4df9a628
commit
3737d35fee
@ -13,6 +13,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -37,6 +38,14 @@ void initialize()
|
|||||||
// Terminate immediately if a fuzzing harness ever tries to create a TCP socket.
|
// Terminate immediately if a fuzzing harness ever tries to create a TCP socket.
|
||||||
CreateSock = [](const CService&) -> std::unique_ptr<Sock> { std::terminate(); };
|
CreateSock = [](const CService&) -> 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) {
|
||||||
|
if (allow_lookup) {
|
||||||
|
std::terminate();
|
||||||
|
}
|
||||||
|
return WrappedGetAddrInfo(name, false);
|
||||||
|
};
|
||||||
|
|
||||||
bool should_abort{false};
|
bool should_abort{false};
|
||||||
if (std::getenv("PRINT_ALL_FUZZ_TARGETS_AND_ABORT")) {
|
if (std::getenv("PRINT_ALL_FUZZ_TARGETS_AND_ABORT")) {
|
||||||
for (const auto& t : FuzzTargets()) {
|
for (const auto& t : FuzzTargets()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user