From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11163 Path: news.gmane.org!.POSTED!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: Re: [PATCH] regex: fix newline matching with negated brackets Date: Sun, 19 Mar 2017 04:30:43 +0100 Message-ID: <20170319033043.GN2082@port70.net> References: <6600F15C-80E5-4CAE-8749-F77323C58D17@gmail.com> <4CAE9FC3-77C9-473B-9A48-345C81A578A7@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1489894260 6603 195.159.176.226 (19 Mar 2017 03:31:00 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 19 Mar 2017 03:31:00 +0000 (UTC) User-Agent: Mutt/1.6.0 (2016-04-01) To: musl@lists.openwall.com Original-X-From: musl-return-11178-gllmg-musl=m.gmane.org@lists.openwall.com Sun Mar 19 04:30:56 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1cpRYT-0000nn-3x for gllmg-musl@m.gmane.org; Sun, 19 Mar 2017 04:30:53 +0100 Original-Received: (qmail 24049 invoked by uid 550); 19 Mar 2017 03:30:56 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 24028 invoked from network); 19 Mar 2017 03:30:55 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <4CAE9FC3-77C9-473B-9A48-345C81A578A7@gmail.com> Xref: news.gmane.org gmane.linux.lib.musl.general:11163 Archived-At: * Julien Ramseier [2017-03-18 16:00:11 +0100]: > diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c > index 5a7b53a..fb24556 100644 > --- a/src/regex/regcomp.c > +++ b/src/regex/regcomp.c > @@ -636,6 +636,20 @@ static reg_errcode_t parse_bracket(tre_parse_ctx_t *= ctx, const char *s) > goto parse_bracket_done; > =20 > if (neg.negate) { > + /* > + * With REG_NEWLINE, POSIX requires that newlines are not matched by > + * any form of a non-matching list. > + */ > + if (ctx->cflags & REG_NEWLINE) { > + lit =3D tre_new_lit(&ls); > + if (!lit) { > + err =3D REG_ESPACE; > + goto parse_bracket_done; > + } > + lit->code_min =3D '\n'; > + lit->code_max =3D '\n'; > + lit->position =3D -1; > + } > /* Sort the array if we need to negate it. */ > qsort(ls.a, ls.len, sizeof *ls.a, tre_compare_lit); > /* extra lit for the last negated range */ >=20 looks good. thanks >=20 > > Le 17 mars 2017 =E0 14:33, Julien Ramseier a =E9= crit : > >=20 > > With REG_NEWLINE, POSIX says: > > "A in string shall not be matched by a period outside > > a bracket expression or by any form of a non-matching list" > >=20 > > musl currently matches newlines with negated brackets, even if > > REG_NEWLINE is used. Attached patch fixes the issue, although > > I'm not sure if it's the best way to do it. > >=20 > > Also see similar glibc bug: > > https://sourceware.org/bugzilla/show_bug.cgi?id=3D3957 > >=20 > >