From 35364b67468de8715e92e582d2330e61ab46947c Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Tue, 25 Sep 2018 14:31:57 -0400 Subject: [PATCH] rpc: reject non-hex strings for claim_script --- src/wallet/rpcwallet.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1adae5c678..5930bb2e14 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3586,8 +3586,12 @@ static UniValue createrawpegin(const JSONRPCRequest& request, T_tx_ref& txBTCRef CScript witnessProgScript; unsigned int nOut = txBTC.vout.size(); if (request.params.size() > 2) { + const std::string claim_script = request.params[2].get_str(); + if (!IsHex(claim_script)) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Given claim_script is not hex."); + } // If given manually, no need for it to be a witness script - std::vector witnessBytes(ParseHex(request.params[2].get_str())); + std::vector witnessBytes(ParseHex(claim_script)); witnessProgScript = CScript(witnessBytes.begin(), witnessBytes.end()); nOut = GetPeginTxnOutputIndex(txBTC, witnessProgScript); if (nOut == txBTC.vout.size()) {