vm: restrict max size in APPEND

This commit is contained in:
Evgenii Stratonikov 2019-10-17 11:03:35 +03:00
parent 8abcaeee6f
commit 2d56c66bde
2 changed files with 24 additions and 0 deletions

View file

@ -786,10 +786,16 @@ func (v *VM) execute(ctx *Context, op Instruction, parameter []byte) {
switch t := arrElem.value.(type) {
case *ArrayItem:
arr := t.Value().([]StackItem)
if len(arr) >= MaxArraySize {
panic("too long array")
}
arr = append(arr, val)
t.value = arr
case *StructItem:
arr := t.Value().([]StackItem)
if len(arr) >= MaxArraySize {
panic("too long struct")
}
arr = append(arr, val)
t.value = arr
default: