diff options
author | MarcoFalke <falke.marco@gmail.com> | 2017-11-07 11:19:33 -0500 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2017-11-07 11:19:52 -0500 |
commit | 89cc4f905e30b913ca20e4192d538cc5cbe2c38d (patch) | |
tree | d118f2683c71664bf80b4b5368a3e0607986fe96 /src | |
parent | 87d90efd69b64f769116956a5db89e536e9e3714 (diff) | |
parent | a6f33ea77d3a48f06b5c7cfcc20553c9a88d429a (diff) |
Merge #11554: Sanity-check script sizes in bitcoin-tx
a6f33ea77 Sanity-check script sizes in bitcoin-tx (Matt Corallo)
Pull request description:
Tree-SHA512: bb8ecb628763af23816ab085758f6140920a6ff05dcb298129c2bbe584a02a759c700a05740eca77023292c98a5658b2a608fa27d5a948d183f87ed9ab827952
Diffstat (limited to 'src')
-rw-r--r-- | src/bitcoin-tx.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index a20222d05c..b499b15507 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -387,6 +387,10 @@ static void MutateTxAddOutMultiSig(CMutableTransaction& tx, const std::string& s scriptPubKey = GetScriptForWitness(scriptPubKey); } if (bScriptHash) { + if (scriptPubKey.size() > MAX_SCRIPT_ELEMENT_SIZE) { + throw std::runtime_error(strprintf( + "redeemScript exceeds size limit: %d > %d", scriptPubKey.size(), MAX_SCRIPT_ELEMENT_SIZE)); + } // Get the ID for the script, and then construct a P2SH destination for it. scriptPubKey = GetScriptForDestination(CScriptID(scriptPubKey)); } @@ -447,10 +451,19 @@ static void MutateTxAddOutScript(CMutableTransaction& tx, const std::string& str bScriptHash = (flags.find("S") != std::string::npos); } + if (scriptPubKey.size() > MAX_SCRIPT_SIZE) { + throw std::runtime_error(strprintf( + "script exceeds size limit: %d > %d", scriptPubKey.size(), MAX_SCRIPT_SIZE)); + } + if (bSegWit) { scriptPubKey = GetScriptForWitness(scriptPubKey); } if (bScriptHash) { + if (scriptPubKey.size() > MAX_SCRIPT_ELEMENT_SIZE) { + throw std::runtime_error(strprintf( + "redeemScript exceeds size limit: %d > %d", scriptPubKey.size(), MAX_SCRIPT_ELEMENT_SIZE)); + } scriptPubKey = GetScriptForDestination(CScriptID(scriptPubKey)); } |