diff options
Diffstat (limited to 'vendor/github.com/d5/tengo/objects/builtin_convert.go')
-rw-r--r-- | vendor/github.com/d5/tengo/objects/builtin_convert.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/vendor/github.com/d5/tengo/objects/builtin_convert.go b/vendor/github.com/d5/tengo/objects/builtin_convert.go index 7d9a8733..b5f2d05d 100644 --- a/vendor/github.com/d5/tengo/objects/builtin_convert.go +++ b/vendor/github.com/d5/tengo/objects/builtin_convert.go @@ -1,5 +1,7 @@ package objects +import "github.com/d5/tengo" + func builtinString(args ...Object) (Object, error) { argsLen := len(args) if !(argsLen == 1 || argsLen == 2) { @@ -12,6 +14,10 @@ func builtinString(args ...Object) (Object, error) { v, ok := ToString(args[0]) if ok { + if len(v) > tengo.MaxStringLen { + return nil, ErrStringLimit + } + return &String{Value: v}, nil } @@ -117,11 +123,19 @@ func builtinBytes(args ...Object) (Object, error) { // bytes(N) => create a new bytes with given size N if n, ok := args[0].(*Int); ok { + if n.Value > int64(tengo.MaxBytesLen) { + return nil, ErrBytesLimit + } + return &Bytes{Value: make([]byte, int(n.Value))}, nil } v, ok := ToByteSlice(args[0]) if ok { + if len(v) > tengo.MaxBytesLen { + return nil, ErrBytesLimit + } + return &Bytes{Value: v}, nil } |