From ee9adcdc5c6acfee02f08b844c7748c5d389f99a Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 20 May 2020 12:31:52 +0300 Subject: [PATCH] vm: check ByteArray size before converting to Integer --- pkg/vm/stack_item.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/vm/stack_item.go b/pkg/vm/stack_item.go index 83baa2460..d47225d47 100644 --- a/pkg/vm/stack_item.go +++ b/pkg/vm/stack_item.go @@ -524,11 +524,10 @@ func (i *ByteArrayItem) TryBytes() ([]byte, error) { // TryInteger implements StackItem interface. func (i *ByteArrayItem) TryInteger() (*big.Int, error) { - bi := emit.BytesToInt(i.value) - if bi.BitLen() > MaxBigIntegerSizeBits { + if len(i.value) > MaxBigIntegerSizeBits/8 { return nil, errors.New("integer is too big") } - return bi, nil + return emit.BytesToInt(i.value), nil } // Equals implements StackItem interface.