public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/main] Cygwin: regex: fix faulty check for valid range expression Date: Mon, 20 Mar 2023 11:58:44 +0000 (GMT) [thread overview] Message-ID: <20230320115844.B07793858033@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=59241913330c15d25ea569f1309af1c746dc07fa commit 59241913330c15d25ea569f1309af1c746dc07fa Author: Corinna Vinschen <corinna@vinschen.de> AuthorDate: Thu Mar 16 21:09:53 2023 +0100 Commit: Corinna Vinschen <corinna@vinschen.de> CommitDate: Mon Mar 20 12:58:03 2023 +0100 Cygwin: regex: fix faulty check for valid range expression Except for the "C" or "POSIX" locale, checking for start <= finish is always wrong. Range start must be <= range finish in terms of the locale's collating order. So make sure to call always wcscoll(), even in the "C"/"POSIX" locale, which makes wcscoll equivalent to wcscmp anyway. Signed-off-by: Corinna Vinschen <corinna@vinschen.de> Diff: --- winsup/cygwin/regex/regcomp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/winsup/cygwin/regex/regcomp.c b/winsup/cygwin/regex/regcomp.c index 418e24a90ad2..7899ae7fce3c 100644 --- a/winsup/cygwin/regex/regcomp.c +++ b/winsup/cygwin/regex/regcomp.c @@ -1145,7 +1145,7 @@ p_b_term(struct parse *p, cset *cs) #else if (MB_CUR_MAX > 1) { #endif - (void)REQUIRE(start <= finish, REG_ERANGE); + (void)REQUIRE(p_range_cmp(start, finish) <= 0, REG_ERANGE); CHaddrange(p, cs, start, finish); } else { (void)REQUIRE(p_range_cmp(start, finish) <= 0, REG_ERANGE); @@ -1665,8 +1665,6 @@ CHaddrange(struct parse *p, cset *cs, wint_t min, wint_t max) for (; min < NC && min <= max; min++) CHadd(p, cs, min); - if (min >= max) - return; newranges = reallocarray(cs->ranges, cs->nranges + 1, sizeof(*cs->ranges)); if (newranges == NULL) {
reply other threads:[~2023-03-20 11:58 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230320115844.B07793858033@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@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: linkBe 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).