core: check stack length before returning false verification result

We must be sure that stack has no other items before returning `false`
verification result. It is an error in both cases, but by preserving the
order we know exactly that it was correct `false` on stack.
This commit is contained in:
Anna Shaleva 2020-12-10 10:42:12 +03:00
parent f0dba26d43
commit 2ab0e6c399

View file

@ -1670,12 +1670,12 @@ func (bc *Blockchain) verifyHashAgainstScript(hash util.Uint160, witness *transa
if err != nil {
return 0, fmt.Errorf("%w: invalid return value", ErrVerificationFailed)
}
if !res {
return 0, fmt.Errorf("%w: invalid signature", ErrVerificationFailed)
}
if vm.Estack().Len() != 0 {
return 0, fmt.Errorf("%w: expected exactly one returned value", ErrVerificationFailed)
}
if !res {
return 0, fmt.Errorf("%w: invalid signature", ErrVerificationFailed)
}
} else {
return 0, fmt.Errorf("%w: no result returned from the script", ErrVerificationFailed)
}