mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 11:41:48 +00:00
vm: restrict max size in NEWARRAY/NEWSTRUCT
This commit is contained in:
parent
85f7732d44
commit
8abcaeee6f
2 changed files with 26 additions and 4 deletions
14
pkg/vm/vm.go
14
pkg/vm/vm.go
|
@ -753,8 +753,11 @@ func (v *VM) execute(ctx *Context, op Instruction, parameter []byte) {
|
|||
case *ArrayItem:
|
||||
v.estack.PushVal(t)
|
||||
default:
|
||||
n := item.BigInt()
|
||||
items := makeArrayOfFalses(int(n.Int64()))
|
||||
n := item.BigInt().Int64()
|
||||
if n > MaxArraySize {
|
||||
panic("too long array")
|
||||
}
|
||||
items := makeArrayOfFalses(int(n))
|
||||
v.estack.PushVal(&ArrayItem{items})
|
||||
}
|
||||
|
||||
|
@ -766,8 +769,11 @@ func (v *VM) execute(ctx *Context, op Instruction, parameter []byte) {
|
|||
case *StructItem:
|
||||
v.estack.PushVal(t)
|
||||
default:
|
||||
n := item.BigInt()
|
||||
items := makeArrayOfFalses(int(n.Int64()))
|
||||
n := item.BigInt().Int64()
|
||||
if n > MaxArraySize {
|
||||
panic("too long struct")
|
||||
}
|
||||
items := makeArrayOfFalses(int(n))
|
||||
v.estack.PushVal(&StructItem{items})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue