Skip to content

Commit

Permalink
OP_CODESEPARATOR bug fix
Browse files Browse the repository at this point in the history
Off by one bug, the subscript does not include the opcode separator itself, so the slice of the script should be from just after the op code separator - not before.

This took about 16 hours to find 😫

Signed-off-by: Darren Kellenschwiler <deggen@kschw.com>
  • Loading branch information
sirdeggen committed Jul 26, 2023
1 parent ad06c6a commit 4669dcd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bscript/interpreter/thread.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,11 @@ func (t *thread) SetStack(data [][]byte) {

// subScript returns the script since the last OP_CODESEPARATOR.
func (t *thread) subScript() ParsedScript {
return t.scripts[t.scriptIdx][t.lastCodeSep:]
skip := 0
if t.lastCodeSep > 0 {
skip = t.lastCodeSep + 1 // +1 to skip the opcode separator itself
}
return t.scripts[t.scriptIdx][skip:]
}

// checkHashTypeEncoding returns whether the passed hashtype adheres to
Expand Down

0 comments on commit 4669dcd

Please sign in to comment.