stackitem: return error in TryBytes() for big byte strings

Follow neo-project/neo-vm#349.
This commit is contained in:
Roman Khimov 2020-08-21 21:05:47 +03:00
parent a7670303e8
commit 93f51f922a
3 changed files with 13 additions and 2 deletions

View file

@ -354,6 +354,17 @@ func TestVerifyHashAgainstScript(t *testing.T) {
err := bc.verifyHashAgainstScript(hash.Hash160(verif), w, ic, false, gas)
require.True(t, errors.Is(err, ErrVerificationFailed))
})
t.Run("BadResult", func(t *testing.T) {
verif := make([]byte, 66)
verif[0] = byte(opcode.PUSHDATA1)
verif[1] = 64
w := &transaction.Witness{
InvocationScript: []byte{byte(opcode.NOP)},
VerificationScript: verif,
}
err := bc.verifyHashAgainstScript(hash.Hash160(verif), w, ic, false, gas)
require.True(t, errors.Is(err, ErrVerificationFailed))
})
t.Run("TooManyResults", func(t *testing.T) {
verif := []byte{byte(opcode.NOP)}
w := &transaction.Witness{

View file

@ -507,7 +507,7 @@ func (i *ByteArray) String() string {
// TryBool implements Item interface.
func (i *ByteArray) TryBool() (bool, error) {
if len(i.value) > MaxBigIntegerSizeBits/8 {
return true, nil
return false, errors.New("too big byte string")
}
for _, b := range i.value {
if b != 0 {

@ -1 +1 @@
Subproject commit 359e8631ee2ddfefe8261afcec1a5bab9d9bddf9
Subproject commit 377464ed475a3de108e1bf9c834bd2279b72624e