rpc: Actually throw help when passed invalid number of params#15401
Merged
laanwj merged 2 commits intobitcoin:masterfrom Feb 25, 2019
Merged
rpc: Actually throw help when passed invalid number of params#15401laanwj merged 2 commits intobitcoin:masterfrom
laanwj merged 2 commits intobitcoin:masterfrom
Conversation
promag
reviewed
Feb 20, 2019
Contributor
promag
left a comment
There was a problem hiding this comment.
Tested with master binary and functional test fails.
fa910b0 to
fa4ce70
Compare
promag
reviewed
Feb 20, 2019
| break; | ||
| } | ||
| } | ||
| return num_required_args <= num_args && num_args <= m_args.size(); |
Contributor
There was a problem hiding this comment.
nit, could early return with if (num_args > m_args.size()) return false;.
Member
Author
There was a problem hiding this comment.
I think this is the wrong place to overoptimize
| bool RPCHelpMan::IsValidNumArgs(size_t num_args) const | ||
| { | ||
| size_t num_required_args = 0; | ||
| for (size_t n = m_args.size(); n > 0; --n) { |
Contributor
There was a problem hiding this comment.
nit, could change condition to n > num_args?
Member
Author
There was a problem hiding this comment.
No, that would be incorrect
Member
Please, let's not start nitting about copyright years. In as far as they matter at all (we don't know!) updating these once per year is enough. |
Member
|
utACK fa4ce70 |
laanwj
added a commit
that referenced
this pull request
Feb 25, 2019
…params fa4ce70 rpc: Actually throw help when passed invalid number of params (MarcoFalke) fa05626 rpc: Add RPCHelpMan::IsValidNumArgs() (MarcoFalke) Pull request description: Can be tested by * running the included test against an old binary (compiled without this patch) * calling `setban 1 "add" 3 4 5 6 7 8 9 0` in the gui Tree-SHA512: aa6a25bbe6f40722913ea292252a62a4012c964eed9f4035335a2e2d13be98eb60f368e8a3251a104a26a62c08b2cb926b06e5ab1418ef1cf4abdd71d87c2919
deadalnix
pushed a commit
to Bitcoin-ABC/bitcoin-abc
that referenced
this pull request
May 22, 2020
Summary: * rpc: Add RPCHelpMan::IsValidNumArgs() This is a backport of Core [[bitcoin/bitcoin#15401 | PR15401]] Depends on D6064 Test Plan: ninja all check-all Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: majcosta Differential Revision: https://reviews.bitcoinabc.org/D6220
kwvg
added a commit
to kwvg/dash
that referenced
this pull request
Dec 12, 2021
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Can be tested by
setban 1 "add" 3 4 5 6 7 8 9 0in the gui