From: наб <nabijaczleweli@nabijaczleweli.xyz>
To: libc-alpha@sourceware.org
Subject: [PATCH v3 2/3] posix: regcomp(): clear RE_DOT_NOT_NULL
Date: Fri, 28 Apr 2023 14:36:42 +0200 [thread overview]
Message-ID: <b67fbdf78d04ae4e8c8a6eec009b664006b0c1a2.1682685278.git.nabijaczleweli@nabijaczleweli.xyz> (raw)
In-Reply-To: <9dee3d2ba84f09e883cf7a7dfcda486fda735382.1682685278.git.nabijaczleweli@nabijaczleweli.xyz>
[-- Attachment #1: Type: text/plain, Size: 1357 bytes --]
The POSIX API always stops at first NUL so there's no change for that.
The BSD REG_STARTEND API, with its explicit range, can include NULs
within that range, and those NULs are matched with . and [^].
Heretofor, for a string of "a\0c", glibc would match "[^q]c", but not
".c". This is both inconsistent and nonconformant to BSD REG_STARTEND.
With this patch, they're identical like you'd expect, and the
tst-reg-startend.c: ..c: a^@c: no match$
failure is removed.
Another approach would be to remove it from _RE_SYNTAX_POSIX_COMMON,
but it's unclear to me what the custody chain is like for that and what
other regex APIs glibc offers that could be affected by this.
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
Keep me in CC, please.
posix/regcomp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/posix/regcomp.c b/posix/regcomp.c
index 647b18ba9e..cbd9bfc673 100644
--- a/posix/regcomp.c
+++ b/posix/regcomp.c
@@ -462,7 +462,7 @@ regcomp (regex_t *__restrict preg, const char *__restrict pattern, int cflags)
{
reg_errcode_t ret;
reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED
- : RE_SYNTAX_POSIX_BASIC);
+ : RE_SYNTAX_POSIX_BASIC) & ~RE_DOT_NOT_NULL;
preg->buffer = NULL;
preg->allocated = 0;
--
2.30.2
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-04-28 12:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-28 12:36 [PATCH v3 1/3] posix: add (failing) test for REG_STARTEND наб
2023-04-28 12:36 ` наб [this message]
2023-04-28 12:36 ` [PATCH v3 3/3] posix: regexec(): fix REG_STARTEND, pmatch->rm_so != 0 w/^ anchor наб
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b67fbdf78d04ae4e8c8a6eec009b664006b0c1a2.1682685278.git.nabijaczleweli@nabijaczleweli.xyz \
--to=nabijaczleweli@nabijaczleweli.xyz \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).