Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20261129190745.GI3542221@port70.net>
Date: Sun, 29 Nov 2026 20:07:45 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: Rich Felker <dalias@...c.org>, Georg Meyer <dev@...roup.ch>,
	musl@...ts.openwall.com
Subject: Re: regcomp: NULL dereference in marksub when
 tre_ast_new_union fails, under a failed allocation

* Szabolcs Nagy <nsz@...t70.net> [2026-11-29 17:38:45 +0100]:
> * Rich Felker <dalias@...c.org> [2026-11-29 09:53:40 -0500]:
> > 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.

attaching a fix

View attachment "0001-regex-fix-missing-alloc-failure-checks-in-regcomp.patch" of type "text/x-diff" (1322 bytes)

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.