diff options
| author | Peter Todd <[email protected]> | 2014-03-10 22:43:15 -0400 |
|---|---|---|
| committer | Peter Todd <[email protected]> | 2014-05-08 00:55:01 -0400 |
| commit | 787ee0c91394b0ae16ca2500dbacf9349e65b6bc (patch) | |
| tree | fddc4dec2f7085610253eb4f521149bc9b95653f /src/keystore.cpp | |
| parent | Increase IsStandard() scriptSig length (diff) | |
| download | discoin-787ee0c91394b0ae16ca2500dbacf9349e65b6bc.tar.xz discoin-787ee0c91394b0ae16ca2500dbacf9349e65b6bc.zip | |
Check redeemScript size does not exceed 520 byte limit
redeemScripts >520bytes can't be spent due to the
MAX_SCRIPT_ELEMENT_SIZE limit; previously the addmultisigaddress and
createmultisig RPC calls would let you violate that limit unknowingly.
Also made the wallet code itself check the redeemScript prior to adding
it to the wallet, which in the (rare) instance that a user has added an
invalid oversized redeemScript to their wallet causes an error on
startup. The affected key isn't added to the wallet; other keys are
unaffected.
Diffstat (limited to 'src/keystore.cpp')
| -rw-r--r-- | src/keystore.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/keystore.cpp b/src/keystore.cpp index 46402ea25..594e0c61d 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; |