summaryrefslogtreecommitdiff
path: root/jsi.h
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2021-09-07 18:02:28 +0200
committerTor Andersson <tor.andersson@artifex.com>2021-09-07 18:02:28 +0200
commitb06a5e9b02688e8d5c355544ce4130b4045c5c0b (patch)
tree80110e1a88bdd33d86275371b7518c829820f848 /jsi.h
parent453d28fcc0fa9dcd35ecd0050d8cec395bb161f2 (diff)
Bug 704238: Limit max string lengths.
Check string length when creating strings to not exceed a maximum, so we avoid integer overflows when concatenating strings. The string limit must be small enough that we'll not integer overflow in one concatenation (A + B + 1 must not overflow while still exceeding the string limit). Set the limit to 64KB for now. If we need 2GB strings then we will have to use double or int64 variables when calculating string lengths.
Diffstat (limited to 'jsi.h')
-rw-r--r--jsi.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/jsi.h b/jsi.h
index 59dcfbf..b4415ac 100644
--- a/jsi.h
+++ b/jsi.h
@@ -93,6 +93,9 @@ typedef struct js_StackTrace js_StackTrace;
#ifndef JS_ASTLIMIT
#define JS_ASTLIMIT 100 /* max nested expressions */
#endif
+#ifndef JS_STRLIMIT
+#define JS_STRLIMIT (1<<16) /* max string length */
+#endif
/* instruction size -- change to int if you get integer overflow syntax errors */