-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net processing: clamp PeerManager::Options user input #28149
Merged
glozow
merged 3 commits into
bitcoin:master
from
stickies-v:2023-07/peerman-opts-check-bounds
Aug 9, 2023
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,18 +3,21 @@ | |||||
#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::max(int64_t{0}, *value)); | ||||||
options.max_orphan_txs = uint32_t((std::clamp<int64_t>(*value, 0, std::numeric_limits<uint32_t>::max()))); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
nit, if you re-touch? |
||||||
} | ||||||
|
||||||
if (auto value{argsman.GetIntArg("-blockreconstructionextratxn")}) { | ||||||
options.max_extra_txs = size_t(std::max(int64_t{0}, *value)); | ||||||
options.max_extra_txs = uint32_t((std::clamp<int64_t>(*value, 0, std::numeric_limits<uint32_t>::max()))); | ||||||
stickies-v marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
} | ||||||
|
||||||
if (auto value{argsman.GetBoolArg("-capturemessages")}) options.capture_messages = *value; | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated: May be good to write a clang-tidy plugin to enforce the limits are compile-time constants and in range to avoid silent UB at runtime?
The in-range one can be submitted to upstream and the other check can be done in this repo.