diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-10-02 15:10:21 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-10-02 15:10:40 +0200 |
commit | 339da9ca4143b5bb5cbe4d0713ae49661af956a6 (patch) | |
tree | 0ffb6e62b2a5523b061128eccb5328448797cbee /src | |
parent | c5c77bdcc632997dbd1b7633c2f3f3505cd864df (diff) | |
parent | 5ddf56045ad65162c7cd5c757c81d9446299a5aa (diff) |
Merge #11411: script: Change SignatureHash input index check to an assert.
5ddf560 script: Change SignatureHash input index check to an assert. (Jim Posen)
Pull request description:
In the SignatureHash function, the input index must refer to a valid index. This is not enforced equally in the segwit/non-segwit branches and should be an assertion rather than returning a error hash.
Tree-SHA512: a775fc9e9bd9835c0ab36368aa45ab3d53e38f31fd4d2b8684a77ee6028c854c363df038681a59358b30138957573ad63b71d4a722c16e0830fb4fa72669ef39
Diffstat (limited to 'src')
-rw-r--r-- | src/script/interpreter.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index 7315500e3b..77314e8cb2 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -1175,6 +1175,8 @@ PrecomputedTransactionData::PrecomputedTransactionData(const CTransaction& txTo) uint256 SignatureHash(const CScript& scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType, const CAmount& amount, SigVersion sigversion, const PrecomputedTransactionData* cache) { + assert(nIn < txTo.vin.size()); + if (sigversion == SIGVERSION_WITNESS_V0) { uint256 hashPrevouts; uint256 hashSequence; @@ -1221,10 +1223,6 @@ uint256 SignatureHash(const CScript& scriptCode, const CTransaction& txTo, unsig } static const uint256 one(uint256S("0000000000000000000000000000000000000000000000000000000000000001")); - if (nIn >= txTo.vin.size()) { - // nIn out of range - return one; - } // Check for invalid use of SIGHASH_SINGLE if ((nHashType & 0x1f) == SIGHASH_SINGLE) { |