about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2016-01-31 16:46:46 +0100
committerRich Felker <dalias@aerifal.cx>2016-01-31 17:33:54 -0500
commit2810b30fc3c515e38d6acabe87de7b48bb8bfc7b (patch)
tree16952c91c5b186aa25faea2cc2e257084c7b0265 /src
parent3b27725385614d44add9351191765181edc3f4c1 (diff)
downloadmusl-2810b30fc3c515e38d6acabe87de7b48bb8bfc7b.tar.gz
musl-2810b30fc3c515e38d6acabe87de7b48bb8bfc7b.tar.xz
musl-2810b30fc3c515e38d6acabe87de7b48bb8bfc7b.zip
regex: increase the stack tre uses for tnfa creation
10k elements stack is increased to 1000k, otherwise tnfa creation fails
for reasonable sized patterns: a single literal char can add 7 elements
to this stack, so regcomp of an 1500 char long pattern (with only litral
chars) fails with REG_ESPACE. (the new limit allows about < 150k chars,
this arbitrary limit allows most command line regex usage.)

ideally there would be no upper bound: regcomp dynamically reallocates
this buffer, every reallocation checks for allocation failure and at
the end this stack is freed so there is no reason for special bound.
however that may have unwanted effect on regcomp and regexec runtime
so this is a conservative change.
Diffstat (limited to 'src')
-rw-r--r--src/regex/regcomp.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c
index 7ce29889..da6abd18 100644
--- a/src/regex/regcomp.c
+++ b/src/regex/regcomp.c
@@ -2688,7 +2688,7 @@ regcomp(regex_t *restrict preg, const char *restrict regex, int cflags)
 
   /* Allocate a stack used throughout the compilation process for various
      purposes. */
-  stack = tre_stack_new(512, 10240, 128);
+  stack = tre_stack_new(512, 1024000, 128);
   if (!stack)
     return REG_ESPACE;
   /* Allocate a fast memory allocator. */