mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-11 11:16:09 -05:00
![glozow](/assets/img/avatar_default.png)
547fa52443
net processing: clamp -blockreconstructionextratxn to uint32_t bounds (stickies-v)e451d1e3c6
net processing: clamp -maxorphantx to uint32_t bounds (stickies-v)aa89e04e07
doc: document PeerManager::Options members (stickies-v) Pull request description: Avoid out-of-bounds user input for `PeerManager::Options` by safely clamping `-maxorphantx` and `-blockreconstructionextratxn`, and avoid platform-specific behaviour by changing `PeerManager::Options::max_extra_txs` from `size_t` to a `uint32_t`. Addresses https://github.com/bitcoin/bitcoin/pull/27499#pullrequestreview-1544114932. Also documents all `PeerManager::Options` members, addressing https://github.com/bitcoin/bitcoin/pull/27499#discussion_r1272302469. ACKs for top commit: dergoegge: Code review ACK547fa52443
glozow: reACK547fa52443
Tree-SHA512: 042d47b35bb8a7b29ef3dadd4c0c5d26f13a8f174f33687855d603c19f8de0fcbbda94418453331e149885412d4edd5f402d640d938f6d94b4dcf54e2fdbbcc9
29 lines
910 B
C++
29 lines
910 B
C++
#include <node/peerman_args.h>
|
|
|
|
#include <common/args.h>
|
|
#include <net_processing.h>
|
|
|
|
#include <algorithm>
|
|
#include <limits>
|
|
|
|
namespace node {
|
|
|
|
void ApplyArgsManOptions(const ArgsManager& argsman, PeerManager::Options& options)
|
|
{
|
|
if (auto value{argsman.GetBoolArg("-txreconciliation")}) options.reconcile_txs = *value;
|
|
|
|
if (auto value{argsman.GetIntArg("-maxorphantx")}) {
|
|
options.max_orphan_txs = uint32_t((std::clamp<int64_t>(*value, 0, std::numeric_limits<uint32_t>::max())));
|
|
}
|
|
|
|
if (auto value{argsman.GetIntArg("-blockreconstructionextratxn")}) {
|
|
options.max_extra_txs = uint32_t((std::clamp<int64_t>(*value, 0, std::numeric_limits<uint32_t>::max())));
|
|
}
|
|
|
|
if (auto value{argsman.GetBoolArg("-capturemessages")}) options.capture_messages = *value;
|
|
|
|
if (auto value{argsman.GetBoolArg("-blocksonly")}) options.ignore_incoming_txs = *value;
|
|
}
|
|
|
|
} // namespace node
|
|
|