Skip to content
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

rpc: Actually throw help when passed invalid number of params #15401

Merged
merged 2 commits into from Feb 25, 2019

Conversation

Projects
None yet
3 participants
@MarcoFalke
Copy link
Member

commented Feb 13, 2019

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

@MarcoFalke MarcoFalke added this to the 0.18.0 milestone Feb 18, 2019

@promag
Copy link
Member

left a comment

Tested with master binary and functional test fails.

Show resolved Hide resolved src/rpc/util.cpp Outdated

MarcoFalke added some commits Feb 13, 2019

@MarcoFalke MarcoFalke force-pushed the MarcoFalke:Mf1902-rpcNumArgs branch from fa910b0 to fa4ce70 Feb 20, 2019

@promag
Copy link
Member

left a comment

Tested ACK fa4ce70.

Could update license year in test/functional/rpc_getblockstats.py.

break;
}
}
return num_required_args <= num_args && num_args <= m_args.size();

This comment has been minimized.

Copy link
@promag

promag Feb 20, 2019

Member

nit, could early return with if (num_args > m_args.size()) return false;.

This comment has been minimized.

Copy link
@MarcoFalke

MarcoFalke Feb 20, 2019

Author Member

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) {

This comment has been minimized.

Copy link
@promag

promag Feb 20, 2019

Member

nit, could change condition to n > num_args?

This comment has been minimized.

Copy link
@MarcoFalke

MarcoFalke Feb 20, 2019

Author Member

No, that would be incorrect

@laanwj

This comment has been minimized.

Copy link
Member

commented Feb 25, 2019

Could update license year in test/functional/rpc_getblockstats.py.

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.

@laanwj

This comment has been minimized.

Copy link
Member

commented Feb 25, 2019

utACK fa4ce70

@laanwj laanwj merged commit fa4ce70 into bitcoin:master Feb 25, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

laanwj added a commit that referenced this pull request Feb 25, 2019

Merge #15401: rpc: Actually throw help when passed invalid number of …
…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

@MarcoFalke MarcoFalke deleted the MarcoFalke:Mf1902-rpcNumArgs branch Feb 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.