Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 31 Jan 2016 08:04:45 -0800
From: Khem Raj <raj.khem@...il.com>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] regex: increase the stack tre uses for tnfa creation

On Sun, Jan 31, 2016 at 7:46 AM, Szabolcs Nagy <nsz@...t70.net> wrote:
> 10k elements stack is increased to 1000k,

It seems this stack is on heap is that right ?
if not then does this enforce some higher minimum limit on stack

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.
> ---
>  src/regex/regcomp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c
> index 7ce2988..da6abd1 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. */
> --
> 2.7.0
>

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.