Skip to content

Commit

Permalink
[rpc] ParseHash: Fail when length is not 64
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke committed Oct 31, 2016
1 parent d2143dc commit fa32619
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/rpc/server.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit fa32619

Please sign in to comment.