Merge #255: fix incorrect bounds check to wit.vtxinwit access in ContextualCheckBlock

feb64d9 cherry-pick of aa2e0f09ec from bitcoin repository (Arvid Norberg)
d8a18ef fix incorrect bounds check to wit.vtxinwit access in ContextualCheckBlock (Arvid Norberg)
This commit is contained in:
Gregory Sanders 2017-09-11 08:48:44 -04:00
commit 1e1a2e580e
No known key found for this signature in database
GPG key ID: F3F68E2D86A48FDB
2 changed files with 4 additions and 1 deletions

View file

@ -38,6 +38,7 @@ env:
before_install:
- export PATH=$(echo $PATH | tr ':' "\n" | sed '/\/opt\/python/d' | tr "\n" ":" | sed "s|::|:|g")
- export PATH=$(echo $PATH | tr ':' "\n" | sed '/\/opt\/pyenv/d' | tr "\n" ":" | sed "s|::|:|g")
install:
- if [ -n "$PPA" ]; then travis_retry sudo add-apt-repository "$PPA" -y; fi
- if [ -n "$DPKG_ADD_ARCH" ]; then sudo dpkg --add-architecture "$DPKG_ADD_ARCH" ; fi

View file

@ -3888,7 +3888,9 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, const Co
int commitpos = GetWitnessCommitmentIndex(block);
if (commitpos != -1) {
uint256 hashWitness = BlockWitnessMerkleRoot(block);
if ((block.vtx[0]->wit.vtxinwit.size() > 0 &&block.vtx[0]->wit.vtxinwit[0].scriptWitness.stack.size() != 1) || block.vtx[0]->wit.vtxinwit[0].scriptWitness.stack[0].size() != 32) {
if (block.vtx[0]->wit.vtxinwit.empty()
|| block.vtx[0]->wit.vtxinwit[0].scriptWitness.stack.size() != 1
|| block.vtx[0]->wit.vtxinwit[0].scriptWitness.stack[0].size() != 32) {
return state.DoS(100, false, REJECT_INVALID, "bad-witness-nonce-size", true, strprintf("%s : invalid witness nonce size", __func__));
}
CHash256().Write(hashWitness.begin(), 32).Write(&block.vtx[0]->wit.vtxinwit[0].scriptWitness.stack[0][0], 32).Finalize(hashWitness.begin());