summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/d5/tengo/objects/builtin_convert.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-03-05 23:08:54 +0100
committerWim <wim@42.be>2019-03-05 23:10:45 +0100
commit325d62b41c03f0530513a4f404cc8d7349b6885b (patch)
treed6f9f2809bdcd3a35b696b412c24cf6f54ddab78 /vendor/github.com/d5/tengo/objects/builtin_convert.go
parente955a056e2aa4a07c6375315113886b2ee86138c (diff)
downloadmatterbridge-msglm-325d62b41c03f0530513a4f404cc8d7349b6885b.tar.gz
matterbridge-msglm-325d62b41c03f0530513a4f404cc8d7349b6885b.tar.bz2
matterbridge-msglm-325d62b41c03f0530513a4f404cc8d7349b6885b.zip
Update vendor d5/tengo
Diffstat (limited to 'vendor/github.com/d5/tengo/objects/builtin_convert.go')
-rw-r--r--vendor/github.com/d5/tengo/objects/builtin_convert.go14
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
}