Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20261129145340.GB5716@brightrain.aerifal.cx>
Date: Sun, 29 Nov 2026 09:53:40 -0500
From: Rich Felker <dalias@...c.org>
To: Georg Meyer <dev@...roup.ch>
Cc: musl@...ts.openwall.com
Subject: Re: regcomp: NULL dereference in marksub when
 tre_ast_new_union fails, under a failed allocation

On Sat, Nov 28, 2026 at 09:55:53PM -0500, Rich Felker wrote:
> On Sat, Nov 28, 2026 at 09:07:28PM -0500, Georg Meyer wrote:
> > In src/regex/regcomp.c, around the end of group/alternation parsing:
> > 
> >     nunion = tre_ast_new_union(ctx->mem, nunion, nbranch);
> >     nbranch = 0;
> >     ...
> >     err = marksub(ctx, nunion, tre_stack_pop_int(stack));
> > 
> > tre_ast_new_union's result is never checked before it is passed into
> > marksub().
> 
> Thanks.

The line:

	nbranch = tre_ast_new_catenation(ctx->mem, nbranch, ctx->n);

just above also looks unchecked, and like it will not crash but
instead misparse the regex 'successfully' if allocation fails. This
might be benign if failures in the internal tre allocation are
"sticky", but it should also be fixed.

I did a grep for all tre_ast_new_* in the file and did not spot any
other places missing checks, but it'd be great if someone else is
interested in double-checking.

Rich

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.