RPCConsole: Throw when overflowing size_t type for array indices

This commit is contained in:
MarcoFalke committed 2021-10-05 14:28:57 +02:00
1 parent c79d9fb2f6
commit faa5e171e6
1 file changed
+5 -4
+5 -4
View File
@@ -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);