mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-10 04:33:59 +01:00
Merge bitcoin/bitcoin#31235: addrman: cap the max_pct to not exceed the maximum number of addresses
9c5775c331addrman: cap the `max_pct` to not exceed the maximum number of addresses (brunoerg) Pull request description: Fixes #31234 This PR fixes a bad alloc issue in `GetAddresses` by capping the value `max_pct`. In practice, values greater than 100 should be treated as 100 since it's the percentage of addresses to return. Also, it limites the value `max_pct` in connman target to exercise values between 0 and 100. ACKs for top commit: adamandrews1: Code Review ACK9c5775c331marcofleon: Tested ACK9c5775c331. Reproduced the crash on master and checked that this fixed it. The checks added to `GetAddr_` look reasonable. mzumsande: Code Review ACK9c5775c331vasild: ACK9c5775c331Tree-SHA512: 2957ae561ccc37df71f43c1863216d2e563522ea70b9a4baee6990e0b4a1ddadccabdcb9115c131a9a57480367b5ebdd03e0e3d4c8583792e2b7d1911a0a06d3
This commit is contained in:
@@ -110,13 +110,13 @@ FUZZ_TARGET(connman, .init = initialize_connman)
|
||||
},
|
||||
[&] {
|
||||
auto max_addresses = fuzzed_data_provider.ConsumeIntegral<size_t>();
|
||||
auto max_pct = fuzzed_data_provider.ConsumeIntegral<size_t>();
|
||||
auto max_pct = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 100);
|
||||
auto filtered = fuzzed_data_provider.ConsumeBool();
|
||||
(void)connman.GetAddresses(max_addresses, max_pct, /*network=*/std::nullopt, filtered);
|
||||
},
|
||||
[&] {
|
||||
auto max_addresses = fuzzed_data_provider.ConsumeIntegral<size_t>();
|
||||
auto max_pct = fuzzed_data_provider.ConsumeIntegral<size_t>();
|
||||
auto max_pct = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 100);
|
||||
(void)connman.GetAddresses(/*requestor=*/random_node, max_addresses, max_pct);
|
||||
},
|
||||
[&] {
|
||||
|
||||
Reference in New Issue
Block a user