Skip to content

Commit faa5e17

Browse files
author
MarcoFalke
committed
RPCConsole: Throw when overflowing size_t type for array indices
1 parent c79d9fb commit faa5e17

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/qt/rpcconsole.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,11 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes
247247
UniValue subelement;
248248
if (lastResult.isArray())
249249
{
250-
for(char argch: curarg)
251-
if (!IsDigit(argch))
252-
throw std::runtime_error("Invalid result query");
253-
subelement = lastResult[LocaleIndependentAtoi<int>(curarg)];
250+
const auto parsed{ToIntegral<size_t>(curarg)};
251+
if (!parsed) {
252+
throw std::runtime_error("Invalid result query");
253+
}
254+
subelement = lastResult[parsed.value()];
254255
}
255256
else if (lastResult.isObject())
256257
subelement = find_value(lastResult, curarg);

0 commit comments

Comments
 (0)