diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-10-06 19:48:14 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-10-06 19:48:17 +0200 |
commit | 7962c97a2e5affe5dbc01899ef87290bda170347 (patch) | |
tree | 024a08b70ff68050068d4ea05393731d93b57824 /src | |
parent | bb8550b7887db5c30bf363e98017421d20e93aa0 (diff) | |
parent | faa5e171e6bdb8f3b4027a3f06497f0de5abf766 (diff) | |
download | bitcoin-7962c97a2e5affe5dbc01899ef87290bda170347.tar.xz |
Merge bitcoin-core/gui#446: RPCConsole: Throw when overflowing size_t type for array indices
faa5e171e6bdb8f3b4027a3f06497f0de5abf766 RPCConsole: Throw when overflowing size_t type for array indices (MarcoFalke)
Pull request description:
To test:
-> `getblock(getbestblockhash(), 1)[tx][22222222222222222222222222222]`
Before:
<- `868693731dea69a197c13c2cfaa41c9f78fcdeb8ab8e9f8cdf2c9025147ee7d1` (hash of the coinbase tx)
After:
<- `Error: Invalid result query`
ACKs for top commit:
jarolrod:
ACK faa5e171e6bdb8f3b4027a3f06497f0de5abf766
shaavan:
ACK faa5e17
Tree-SHA512: ddff39aae1c15db45928b110a9f1c42eadc5404cdfa89d67ccffc4c6af24091967d43c068ce9e0c1b863cfc4eb5b4f12373a73756a9474f8294e8a44aabc28d8
Diffstat (limited to 'src')
-rw-r--r-- | src/qt/rpcconsole.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 3c0dc5aa40..0c3332ab76 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -247,10 +247,11 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes UniValue subelement; if (lastResult.isArray()) { - for(char argch: curarg) - if (!IsDigit(argch)) - throw std::runtime_error("Invalid result query"); - subelement = lastResult[LocaleIndependentAtoi<int>(curarg)]; + const auto parsed{ToIntegral<size_t>(curarg)}; + if (!parsed) { + throw std::runtime_error("Invalid result query"); + } + subelement = lastResult[parsed.value()]; } else if (lastResult.isObject()) subelement = find_value(lastResult, curarg); |