aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/keystore.cpp3
-rw-r--r--src/rpcmisc.cpp9
-rw-r--r--src/rpcwallet.cpp4
3 files changed, 12 insertions, 4 deletions
diff --git a/src/keystore.cpp b/src/keystore.cpp
index 46402ea25b..594e0c61da 100644
--- a/src/keystore.cpp
+++ b/src/keystore.cpp
@@ -33,6 +33,9 @@ bool CBasicKeyStore::AddKeyPubKey(const CKey& key, const CPubKey &pubkey)
bool CBasicKeyStore::AddCScript(const CScript& redeemScript)
{
+ if (redeemScript.size() > MAX_SCRIPT_ELEMENT_SIZE)
+ return error("CBasicKeyStore::AddCScript() : redeemScripts > %i bytes are invalid", MAX_SCRIPT_ELEMENT_SIZE);
+
LOCK(cs_KeyStore);
mapScripts[redeemScript.GetID()] = redeemScript;
return true;
diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp
index ae154f2ae4..a2694d458a 100644
--- a/src/rpcmisc.cpp
+++ b/src/rpcmisc.cpp
@@ -176,7 +176,7 @@ Value validateaddress(const Array& params, bool fHelp)
//
// Used by addmultisigaddress / createmultisig:
//
-CScript _createmultisig(const Array& params)
+CScript _createmultisig_redeemScript(const Array& params)
{
int nRequired = params[0].get_int();
const Array& keys = params[1].get_array();
@@ -228,6 +228,11 @@ CScript _createmultisig(const Array& params)
}
CScript result;
result.SetMultisig(nRequired, pubkeys);
+
+ if (result.size() > MAX_SCRIPT_ELEMENT_SIZE)
+ throw runtime_error(
+ strprintf("redeemScript exceeds size limit: %d > %d", result.size(), MAX_SCRIPT_ELEMENT_SIZE));
+
return result;
}
@@ -263,7 +268,7 @@ Value createmultisig(const Array& params, bool fHelp)
}
// Construct using pay-to-script-hash:
- CScript inner = _createmultisig(params);
+ CScript inner = _createmultisig_redeemScript(params);
CScriptID innerID = inner.GetID();
CBitcoinAddress address(innerID);
diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp
index a5a7df0867..e21881dbe9 100644
--- a/src/rpcwallet.cpp
+++ b/src/rpcwallet.cpp
@@ -871,7 +871,7 @@ Value sendmany(const Array& params, bool fHelp)
}
// Defined in rpcmisc.cpp
-extern CScript _createmultisig(const Array& params);
+extern CScript _createmultisig_redeemScript(const Array& params);
Value addmultisigaddress(const Array& params, bool fHelp)
{
@@ -908,7 +908,7 @@ Value addmultisigaddress(const Array& params, bool fHelp)
strAccount = AccountFromValue(params[2]);
// Construct using pay-to-script-hash:
- CScript inner = _createmultisig(params);
+ CScript inner = _createmultisig_redeemScript(params);
CScriptID innerID = inner.GetID();
pwalletMain->AddCScript(inner);