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.
This commit is contained in:
Szabolcs Nagy 2016-01-31 16:46:46 +01:00 committed by Rich Felker
parent 3b27725385
commit 2810b30fc3
1 changed files with 1 additions and 1 deletions

View File

@ -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 /* Allocate a stack used throughout the compilation process for various
purposes. */ purposes. */
stack = tre_stack_new(512, 10240, 128); stack = tre_stack_new(512, 1024000, 128);
if (!stack) if (!stack)
return REG_ESPACE; return REG_ESPACE;
/* Allocate a fast memory allocator. */ /* Allocate a fast memory allocator. */