mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-06 19:23:41 +02:00
Merge bitcoin/bitcoin#28832: fuzz: rule-out too deep derivation paths in descriptor parsing targets
a44808fb43fuzz: rule-out too deep derivation paths in descriptor parsing targets (Antoine Poinsot) Pull request description: This fixes the `mocked_descriptor_parse` timeout reported in #28812 and direct the targets more toward what they are intended to fuzz: the descriptor syntax. ACKs for top commit: sipa: utACKa44808fb43achow101: ACKa44808fb43dergoegge: ACKa44808fb43- Not running into timeouts anymore TheCharlatan: ACKa44808fb43Tree-SHA512: a5dd1dbe9adf8f088bdc435addab88b56f435e6d7d2065bd6d5c6d80a32e3f1f97d3d2323131ab233618cd6dcc477c458abe3c4c865ab569449b8bc176231e93
This commit is contained in:
@@ -49,9 +49,21 @@ void initialize_spkm()
|
||||
MOCKED_DESC_CONVERTER.Init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Key derivation is expensive. Deriving deep derivation paths take a lot of compute and we'd rather spend time
|
||||
* elsewhere in this target, like on actually fuzzing the DescriptorScriptPubKeyMan. So rule out strings which could
|
||||
* correspond to a descriptor containing a too large derivation path.
|
||||
*/
|
||||
static bool TooDeepDerivPath(std::string_view desc)
|
||||
{
|
||||
const FuzzBufferType desc_buf{reinterpret_cast<const unsigned char *>(desc.data()), desc.size()};
|
||||
return HasDeepDerivPath(desc_buf);
|
||||
}
|
||||
|
||||
static std::optional<std::pair<WalletDescriptor, FlatSigningProvider>> CreateWalletDescriptor(FuzzedDataProvider& fuzzed_data_provider)
|
||||
{
|
||||
const std::string mocked_descriptor{fuzzed_data_provider.ConsumeRandomLengthString()};
|
||||
if (TooDeepDerivPath(mocked_descriptor)) return {};
|
||||
const auto desc_str{MOCKED_DESC_CONVERTER.GetDescriptor(mocked_descriptor)};
|
||||
if (!desc_str.has_value()) return std::nullopt;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user