mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
Merge bitcoin/bitcoin#21795: fuzz: Terminate immediately if a fuzzing harness tries to perform a DNS lookup (belt and suspenders)
3737d35fee
fuzz: Terminate immediately if a fuzzing harness ever tries to perform a DNS lookup (belts and suspenders) (practicalswift) Pull request description: Terminate immediately if a fuzzing harness tries to perform a DNS lookup (belt and suspenders). Obviously this _should_ never happen, but if it _does_ happen we want immediate termination instead of a DNS lookup :) ACKs for top commit: MarcoFalke: review ACK3737d35fee
Tree-SHA512: 51cd2d32def7f9f052e02f99c354656af1f807cc9fdf592ab765e620bfe660f1ed26e0484763f94aba650424b44959eafaf352bfd0f81aa273e350510e97356e
This commit is contained in:
commit
912cb59490
1 changed files with 9 additions and 0 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
|
@ -37,6 +38,14 @@ void initialize()
|
|||
// Terminate immediately if a fuzzing harness ever tries to create a TCP socket.
|
||||
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};
|
||||
if (std::getenv("PRINT_ALL_FUZZ_TARGETS_AND_ABORT")) {
|
||||
for (const auto& t : FuzzTargets()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue