Browse Source

Merge #9042: [rpc] ParseHash: Fail when length is not 64

fa32619 [rpc] ParseHash: Fail when length is not 64 (MarcoFalke)
0.14
Wladimir J. van der Laan 8 years ago
parent
commit
bc785d7185
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 2
      src/rpc/server.cpp

2
src/rpc/server.cpp

@ -147,6 +147,8 @@ uint256 ParseHashV(const UniValue& v, string strName) @@ -147,6 +147,8 @@ uint256 ParseHashV(const UniValue& v, string strName)
strHex = v.get_str();
if (!IsHex(strHex)) // Note: IsHex("") is false
throw JSONRPCError(RPC_INVALID_PARAMETER, strName+" must be hexadecimal string (not '"+strHex+"')");
if (64 != strHex.length())
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("%s must be of length %d (not %d)", strName, 64, strHex.length()));
uint256 result;
result.SetHex(strHex);
return result;

Loading…
Cancel
Save