rest: Reject + sign in /blockhashbyheight/

This commit is contained in:
MarcoFalke
2025-05-15 21:36:36 +02:00
parent fafd43c691
commit 8888bb499d
2 changed files with 6 additions and 4 deletions

View File

@@ -962,8 +962,8 @@ static bool rest_blockhash_by_height(const std::any& context, HTTPRequest* req,
std::string height_str;
const RESTResponseFormat rf = ParseDataFormat(height_str, str_uri_part);
int32_t blockheight = -1; // Initialization done only to prevent valgrind false positive, see https://github.com/bitcoin/bitcoin/pull/18785
if (!ParseInt32(height_str, &blockheight) || blockheight < 0) {
const auto blockheight{ToIntegral<int32_t>(height_str)};
if (!blockheight || *blockheight < 0) {
return RESTERR(req, HTTP_BAD_REQUEST, "Invalid height: " + SanitizeString(height_str));
}
@@ -974,10 +974,10 @@ static bool rest_blockhash_by_height(const std::any& context, HTTPRequest* req,
ChainstateManager& chainman = *maybe_chainman;
LOCK(cs_main);
const CChain& active_chain = chainman.ActiveChain();
if (blockheight > active_chain.Height()) {
if (*blockheight > active_chain.Height()) {
return RESTERR(req, HTTP_NOT_FOUND, "Block height out of range");
}
pblockindex = active_chain[blockheight];
pblockindex = active_chain[*blockheight];
}
switch (rf) {
case RESTResponseFormat::BINARY: {