From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11159 Path: news.gmane.org!.POSTED!not-for-mail From: Julien Ramseier Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] regex: fix newline matching with negated brackets Date: Sat, 18 Mar 2017 16:00:11 +0100 Message-ID: <4CAE9FC3-77C9-473B-9A48-345C81A578A7@gmail.com> References: <6600F15C-80E5-4CAE-8749-F77323C58D17@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1489849226 6565 195.159.176.226 (18 Mar 2017 15:00:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 18 Mar 2017 15:00:26 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-11174-gllmg-musl=m.gmane.org@lists.openwall.com Sat Mar 18 16:00:22 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 1cpFq9-0001GP-Kt for gllmg-musl@m.gmane.org; Sat, 18 Mar 2017 16:00:21 +0100 Original-Received: (qmail 12245 invoked by uid 550); 18 Mar 2017 15:00:26 -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 12211 invoked from network); 18 Mar 2017 15:00:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=7HIRgwPjBW9O+dflmvpeuee0yZJXVx6c+SoGV6ZU138=; b=X0W0tEhZhQmY8ptca6QRzYoNJDzbjqQacpFLHQtjREzaxzyOjKJ4uIXAQX0KOUF/0F 7O4b+D/9TW2FxN1qjJAqrVfZpltj2IEkv7bTIITn2s9rOR7fEr8rx51ykl+VF1Dh06BW FZWPmbAuWtf1LSaqrRVAgvtZHvFmCq+sWh888cDUeHX77zMm+QOFbqyBpShu3WEGr7ck +Ib+JDHu+bUPYpioDgcoUF4ZvrzdfH2p4037+KmqAZVmfpJPlp1hJhySOz5FMEoW4/+A 8OAQ7owLcb2VPdhStDoK0X3tf1mMr/D4sTsKwdNaQaNXjv1IK474VGp4CNNP4egLFDj2 TjCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=7HIRgwPjBW9O+dflmvpeuee0yZJXVx6c+SoGV6ZU138=; b=jDyUkkkkp1ChZS9hzazc84+JGEyRYxYAeaiL899JbOlkV5JuP2zyZq5r5/SO/Y6QnR VeO7SsLBX59erliT1ednar4GIv6bQNiWaKJJ7TByw49sOJgVCqiuhN+ANbf4vpsIU86s L08/UBVuzQinUxH6Yx+IhNkqa3xXm6Y6gsaZP5WAai/Qp9HoHjWzq9Kdx/6laS1jQHDj s4N2FRgkDtcCM5AEXTbUZ3Q0JKg4w/tNwt6QnnQCiY8ybTiI+GP0ugSwfl9I11kdURdq 8exoaX2nRM57zH+LB5yNmIQYpM38o5zpOjGYCn1ZMp0FQdR8AsG/fnZuIw4mc2MndmDk teAA== X-Gm-Message-State: AFeK/H3+nUslWRC5CR+tBDttZQ++Uuvws4X5m+gRcxsLHa4JHFkiM6xtlemBueZdY7Yn2Q== X-Received: by 10.223.129.4 with SMTP id 4mr14876950wrm.4.1489849213246; Sat, 18 Mar 2017 08:00:13 -0700 (PDT) In-Reply-To: <6600F15C-80E5-4CAE-8749-F77323C58D17@gmail.com> X-Mailer: Apple Mail (2.3124) Xref: news.gmane.org gmane.linux.lib.musl.general:11159 Archived-At: Again with inline patch. I suspect my emails are not received by anyone when adding an = attachment... 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 */ > Le 17 mars 2017 =C3=A0 14:33, Julien Ramseier a = =C3=A9crit : >=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 >