mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-10-10 19:43:13 +02:00
Merge bitcoin-core/gui#446: RPCConsole: Throw when overflowing size_t type for array indices
faa5e171e6
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: ACKfaa5e171e6
shaavan: ACKfaa5e17
Tree-SHA512: ddff39aae1c15db45928b110a9f1c42eadc5404cdfa89d67ccffc4c6af24091967d43c068ce9e0c1b863cfc4eb5b4f12373a73756a9474f8294e8a44aabc28d8
This commit is contained in:
@@ -247,10 +247,11 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes
|
|||||||
UniValue subelement;
|
UniValue subelement;
|
||||||
if (lastResult.isArray())
|
if (lastResult.isArray())
|
||||||
{
|
{
|
||||||
for(char argch: curarg)
|
const auto parsed{ToIntegral<size_t>(curarg)};
|
||||||
if (!IsDigit(argch))
|
if (!parsed) {
|
||||||
throw std::runtime_error("Invalid result query");
|
throw std::runtime_error("Invalid result query");
|
||||||
subelement = lastResult[LocaleIndependentAtoi<int>(curarg)];
|
}
|
||||||
|
subelement = lastResult[parsed.value()];
|
||||||
}
|
}
|
||||||
else if (lastResult.isObject())
|
else if (lastResult.isObject())
|
||||||
subelement = find_value(lastResult, curarg);
|
subelement = find_value(lastResult, curarg);
|
||||||
|
Reference in New Issue
Block a user