diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-10-05 14:47:12 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-10-05 14:28:57 +0200 |
commit | faa5e171e6bdb8f3b4027a3f06497f0de5abf766 (patch) | |
tree | b07e3f4332a3debb3558b3a0905c11ff1ee0d9af /src/qt | |
parent | c79d9fb2f6e5f47dcb0ac45d66a542dad0c8e7e4 (diff) | |
download | bitcoin-faa5e171e6bdb8f3b4027a3f06497f0de5abf766.tar.xz |
RPCConsole: Throw when overflowing size_t type for array indices
Diffstat (limited to 'src/qt')
-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); |