Permalink
Browse files

[rpc] ParseHash: Fail when length is not 64

Github-Pull: #9042
Rebased-From: fa32619
  • Loading branch information...
1 parent 973ca1e commit 5bcb05d4e1304ac3582f1779a25693c0065c69e9 @MarcoFalke MarcoFalke committed with luke-jr Oct 30, 2016
Showing with 2 additions and 0 deletions.
  1. +2 −0 src/rpc/server.cpp
View
@@ -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;

0 comments on commit 5bcb05d

Please sign in to comment.