From f962d703ace5e9af29676311b443d3ca0bfb201d Mon Sep 17 00:00:00 2001 From: barton26 Date: Tue, 31 Aug 2021 16:45:39 -0400 Subject: [PATCH] ParseHash: Fail when length is not 64 --- src/rpc/server.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 988ca7a10d..7ef750531b 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -130,6 +130,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;