vm: check ByteArray size before converting to Integer

This commit is contained in:
Evgenii Stratonikov 2020-05-20 12:31:52 +03:00
parent 8f5f6fba07
commit ee9adcdc5c

View file

@ -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.