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