vm: allow custom limit duing Map\Array\Struct deserialization

This commit is contained in:
Anna Shaleva 2023-02-07 11:39:17 +03:00
parent 15fa65d30f
commit 25ed5fcd60

View file

@ -304,7 +304,7 @@ func (r *deserContext) decodeBinary() Item {
return NewBigInteger(num) return NewBigInteger(num)
case ArrayT, StructT: case ArrayT, StructT:
size := int(r.ReadVarUint()) size := int(r.ReadVarUint())
if size > MaxDeserialized { if size > r.limit {
r.Err = errTooBigElements r.Err = errTooBigElements
return nil return nil
} }
@ -319,7 +319,7 @@ func (r *deserContext) decodeBinary() Item {
return NewStruct(arr) return NewStruct(arr)
case MapT: case MapT:
size := int(r.ReadVarUint()) size := int(r.ReadVarUint())
if size > MaxDeserialized { if size > r.limit/2 {
r.Err = errTooBigElements r.Err = errTooBigElements
return nil return nil
} }