Skip to content

Commit bc785d7

Browse files
committed
Merge #9042: [rpc] ParseHash: Fail when length is not 64
fa32619 [rpc] ParseHash: Fail when length is not 64 (MarcoFalke)
2 parents d316cfe + fa32619 commit bc785d7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/rpc/server.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ uint256 ParseHashV(const UniValue& v, string strName)
147147
strHex = v.get_str();
148148
if (!IsHex(strHex)) // Note: IsHex("") is false
149149
throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be hexadecimal string (not '"+strHex+"')");
150+
if (64 != strHex.length())
151+
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("%s must be of length %d (not %d)", strName, 64, strHex.length()));
150152
uint256 result;
151153
result.SetHex(strHex);
152154
return result;

0 commit comments

Comments
 (0)