diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-07-22 16:55:37 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-07-22 16:55:43 +0200 |
commit | bfa52cbddfaa0e6734f8d229a55a1d2971dea594 (patch) | |
tree | 0055bb14053de7fcdc9300e797531e152514ce44 | |
parent | 3f083a5bbdbb41cfa6be8f9d4b0e306515bfa100 (diff) | |
parent | aaaa9c6019790a1a21a7b4ef01693ac9390ae6d0 (diff) | |
download | bitcoin-bfa52cbddfaa0e6734f8d229a55a1d2971dea594.tar.xz |
Merge bitcoin/bitcoin#22493: fuzz: Extend addrman fuzz test with deserialize
aaaa9c6019790a1a21a7b4ef01693ac9390ae6d0 fuzz: Extend addrman fuzz test with deserialize (MarcoFalke)
Pull request description:
Requested on IRC:
```
[18:01] <vasild> => I think there is a good chance fuzzing addrman unserialize will find more bugs
[18:04] <sipa> definitely
ACKs for top commit:
jonatack:
ACK aaaa9c6019790a1a21a7b4ef01693ac9390ae6d0 per `git diff fa74025 aaaa9c6`
vasild:
ACK aaaa9c6019790a1a21a7b4ef01693ac9390ae6d0
Tree-SHA512: f57d0aecf22a933e48d3181d7398218949588dd0de31218d1d28c825649e55fd60b0de6fbc92d2497cf5639a4adc2061c9bf8216546a2be916feac4f03f16e8f
-rw-r--r-- | src/test/fuzz/addrman.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/test/fuzz/addrman.cpp b/src/test/fuzz/addrman.cpp index 8513f1e6df..92c34e74d9 100644 --- a/src/test/fuzz/addrman.cpp +++ b/src/test/fuzz/addrman.cpp @@ -44,6 +44,17 @@ FUZZ_TARGET_INIT(addrman, initialize_addrman) addr_man.m_asmap.clear(); } } + if (fuzzed_data_provider.ConsumeBool()) { + const std::vector<uint8_t> serialized_data{ConsumeRandomLengthByteVector(fuzzed_data_provider)}; + CDataStream ds(serialized_data, SER_DISK, INIT_PROTO_VERSION); + const auto ser_version{fuzzed_data_provider.ConsumeIntegral<int32_t>()}; + ds.SetVersion(ser_version); + try { + ds >> addr_man; + } catch (const std::ios_base::failure&) { + addr_man.Clear(); + } + } while (fuzzed_data_provider.ConsumeBool()) { CallOneOf( fuzzed_data_provider, |