Skip to content

Commit

Permalink
[rpc] ParseHash: Fail when length is not 64
Browse files Browse the repository at this point in the history
Github-Pull: #9042
Rebased-From: fa326193ad739d1f93da456b3fa73af0bbf9fdd1
  • Loading branch information
MarcoFalke authored and luke-jr committed Dec 2, 2016
1 parent 973ca1e commit 5bcb05d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/rpc/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,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 5bcb05d

Please sign in to comment.