script: enforce stack size on unexecuted branches.
This primarily only affects zero-length scripts. An input script which pushed this many items onto the stack without failing _is not possible_, but with segwit, it is possible. However, a witness program would fail due to cleanstack before there would be any kind of consensus fault. In other words, without this fix, we still remain in consensus with bitcoin core, but ideally we should want to fail for the same reason.
This commit is contained in:
parent
7145d21c9c
commit
5fae0c50a1
@ -589,8 +589,11 @@ Script.prototype.execute = function execute(stack, flags, tx, index, value, vers
|
||||
if (op.isDisabled())
|
||||
throw new ScriptError('DISABLED_OPCODE', op, ip);
|
||||
|
||||
if (negate && !op.isBranch())
|
||||
if (negate && !op.isBranch()) {
|
||||
if (stack.length + alt.length > consensus.MAX_SCRIPT_STACK)
|
||||
throw new ScriptError('STACK_SIZE', op, ip);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (op.data) {
|
||||
if (minimal && !op.isMinimal())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user