aboutsummaryrefslogtreecommitdiff
path: root/src/qt/rpcconsole.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-10-05 14:47:12 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-10-05 14:28:57 +0200
commitfaa5e171e6bdb8f3b4027a3f06497f0de5abf766 (patch)
treeb07e3f4332a3debb3558b3a0905c11ff1ee0d9af /src/qt/rpcconsole.cpp
parentc79d9fb2f6e5f47dcb0ac45d66a542dad0c8e7e4 (diff)
RPCConsole: Throw when overflowing size_t type for array indices
Diffstat (limited to 'src/qt/rpcconsole.cpp')
-rw-r--r--src/qt/rpcconsole.cpp9
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);