Merge bitcoin/bitcoin#22493: fuzz: Extend addrman fuzz test with deserialize

aaaa9c6019 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 aaaa9c6019 per `git diff fa74025 aaaa9c6`
  vasild:
    ACK aaaa9c6019

Tree-SHA512: f57d0aecf22a933e48d3181d7398218949588dd0de31218d1d28c825649e55fd60b0de6fbc92d2497cf5639a4adc2061c9bf8216546a2be916feac4f03f16e8f
This commit is contained in:
MarcoFalke 2021-07-22 16:55:37 +02:00
commit bfa52cbddf
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548

View File

@ -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,