diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-06-17 12:54:24 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-06-17 12:54:27 +0200 |
commit | 6eafa81b32fdbb1d912c513b4b65256ae30a64af (patch) | |
tree | ae1ae2ab6fac47548b3f5ec601fc50e59d294086 /src/test | |
parent | dd24567a243fd71ab2fe991b431f805bcc3f7b3e (diff) | |
parent | fa483e9f68b8b4171dabb25cc88dc2eada454a99 (diff) | |
download | bitcoin-6eafa81b32fdbb1d912c513b4b65256ae30a64af.tar.xz |
Merge bitcoin/bitcoin#22267: fuzz: Speed up crypto fuzz target
fa483e9f68b8b4171dabb25cc88dc2eada454a99 fuzz: Speed up crypto fuzz target (MarcoFalke)
Pull request description:
May fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34962
Similar solution to https://github.com/bitcoin/bitcoin/pull/22005
ACKs for top commit:
practicalswift:
cr ACK fa483e9f68b8b4171dabb25cc88dc2eada454a99: patch looks correct and rationale makes sense
Tree-SHA512: 3788cf9f6ba0f7a0a217cd3a6a825839689425e99e4d6d657981d291a001b0da7c5abb50a68b4ee1c2a8300b87fb92e4e3ccc1171907792b40251e467c33bd53
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/fuzz/crypto.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/test/fuzz/crypto.cpp b/src/test/fuzz/crypto.cpp index eeeac18968..f83747e424 100644 --- a/src/test/fuzz/crypto.cpp +++ b/src/test/fuzz/crypto.cpp @@ -19,6 +19,10 @@ FUZZ_TARGET(crypto) { + // Hashing is expensive with sanitizers enabled, so limit the number of + // calls + int limit_max_ops{30}; + FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; std::vector<uint8_t> data = ConsumeRandomLengthByteVector(fuzzed_data_provider); if (data.empty()) { @@ -36,7 +40,7 @@ FUZZ_TARGET(crypto) SHA3_256 sha3; CSipHasher sip_hasher{fuzzed_data_provider.ConsumeIntegral<uint64_t>(), fuzzed_data_provider.ConsumeIntegral<uint64_t>()}; - while (fuzzed_data_provider.ConsumeBool()) { + while (--limit_max_ops >= 0 && fuzzed_data_provider.ConsumeBool()) { CallOneOf( fuzzed_data_provider, [&] { |