From nobody Fri May 10 01:30:59 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VbBD41mQYz5KTvG; Fri, 10 May 2024 01:31:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VbBD36jfwz4MWn; Fri, 10 May 2024 01:30:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715304659; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mSLxVIRM75I8oXqwbRo4ycJ/LeTjpfOLwn4WBz5chmo=; b=NNES5WcBSZYsCeU+LYYWZINst2FRDlPhT14ynLxeFji06cX24pfyhYPJN+9M5TwK+WJ2nS 9GFbEfPR9dMpva8KIYtBKcbcRoSEuE8+qhETle7bgrr2VAVRVvhQIMCLoUgj7TAQL0tziz FBfZNYCLjoJ3tjmHBMgTaMpOYbU1zLhZFddB80rXvNI3gqQqANnruGsR8wtBK27dymmRWN oyi2+TC2yL9SfuB3wknfSgzYwF+TjBriVzjxT4tUwuWNZJtcZb1K2+80CEovuggdnQY5pC uGDpdiEn/wrolYdmiD1XeyaaffiO7XyTxGrXByp6NKC1SPTWi1Syc+GQPxeAEA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715304659; a=rsa-sha256; cv=none; b=F9nYhgkFvETT0QzVuKzmewHstjm1Zb+5AGl157G5g1JwMaZ5ZXDhYR9/CV1NzJB9uN1Ly6 rDB8ICGfmQSbMhMUSxIzFVZwpjpzrcr0+8WzSDgBBme6ZwgNfGlau8+w6q0MApfBah/8LZ 6bmXouSAs8BOExZ4owYbJgRbLHEeAtl09bnxmyrYuAySanAUmdOvcYv64Dr0SANDoir2F+ 3HUhn4zxIQpz9at5UtyPP+/43XNNCs3pWbPHUxrAE+xCt6v1qY1gzDs/WEkrK1G4P3B5Wg q79gkyJbrq86c8V7+ifwLTo9cNtMZqr0azywQPp7cj676EmA5Gwuei62hQhGtA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715304659; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mSLxVIRM75I8oXqwbRo4ycJ/LeTjpfOLwn4WBz5chmo=; b=NErc4C+oaYh/iE6o2lbqReeBbtUWbSthbDdKRVpeog64oeCCQ8uNNGop39/rOZVRx2ALsE 7cSPX5sbdc4KUFUkTCKL9wwX7+NrtEoAK+hFJZvMgNfZmN8EQa+L9SDBSGsSv4H4YPzC4V b9S4ChVtyYExHvFVUbUuAb256u0gGhrlxEbNTFa9MPmnLMLXyc6VrjrOdfNZ7BoIIscjdU yllFODwVaxnW6iItsao+m5OfWifqnhbqdw+7e9z+gAea3gORNPZgfr7J3eL1rgnLGyCbKi TxeZKd2qmrFaPUiD4Ok6C5bi3deiShtkea8jYINTs2J7rgg0kljxMfOvaTuwQw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VbBD362vvzHSq; Fri, 10 May 2024 01:30:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44A1Uxav082136; Fri, 10 May 2024 01:30:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44A1Ux4h082133; Fri, 10 May 2024 01:30:59 GMT (envelope-from git) Date: Fri, 10 May 2024 01:30:59 GMT Message-Id: <202405100130.44A1Ux4h082133@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Simon J. Gerraty" Subject: git: f77b5b295da3 - main - Allow -DNO_STRICT_REGEX to restore historic regex behavior List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: sjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f77b5b295da3146c3b601767cbc4e85e6713192c Auto-Submitted: auto-generated The branch main has been updated by sjg: URL: https://cgit.FreeBSD.org/src/commit/?id=f77b5b295da3146c3b601767cbc4e85e6713192c commit f77b5b295da3146c3b601767cbc4e85e6713192c Author: Simon J. Gerraty AuthorDate: 2024-05-10 01:29:43 +0000 Commit: Simon J. Gerraty CommitDate: 2024-05-10 01:29:43 +0000 Allow -DNO_STRICT_REGEX to restore historic regex behavior Allow restoring the behavior of '{' as described in regex(3). Ie. only treat it as start of bounds if followed by a digit. If NO_STRICT_REGEX is not defined, the behavior introduced by commit a4a801688c909ef39cbcbc3488bc4fdbabd69d66 is retained, otherwise the previous behavior is restored. Differential Revision: https://reviews.freebsd.org/D45134 --- lib/libc/regex/regcomp.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c index 7481d3ecf240..f34dc322d0bb 100644 --- a/lib/libc/regex/regcomp.c +++ b/lib/libc/regex/regcomp.c @@ -453,7 +453,9 @@ p_ere_exp(struct parse *p, struct branchc *bc) case '*': case '+': case '?': +#ifndef NO_STRICT_REGEX case '{': +#endif SETERROR(REG_BADRPT); break; case '.': @@ -536,6 +538,11 @@ p_ere_exp(struct parse *p, struct branchc *bc) break; } break; +#ifdef NO_STRICT_REGEX + case '{': /* okay as ordinary except if digit follows */ + (void)REQUIRE(!MORE() || !isdigit((uch)PEEK()), REG_BADRPT); + /* FALLTHROUGH */ +#endif default: if (p->error != 0) return (false); @@ -549,11 +556,19 @@ p_ere_exp(struct parse *p, struct branchc *bc) return (false); c = PEEK(); /* we call { a repetition if followed by a digit */ - if (!( c == '*' || c == '+' || c == '?' || c == '{')) + if (!( c == '*' || c == '+' || c == '?' || +#ifdef NO_STRICT_REGEX + (c == '{' && MORE2() && isdigit((uch)PEEK2())) +#else + c == '{' +#endif + )) return (false); /* no repetition, we're done */ +#ifndef NO_STRICT_REGEX else if (c == '{') (void)REQUIRE(MORE2() && \ (isdigit((uch)PEEK2()) || PEEK2() == ','), REG_BADRPT); +#endif NEXT(); (void)REQUIRE(!wascaret, REG_BADRPT); @@ -892,6 +907,9 @@ p_simp_re(struct parse *p, struct branchc *bc) (void)REQUIRE(EATTWO('\\', ')'), REG_EPAREN); break; case BACKSL|')': /* should not get here -- must be user */ +#ifdef NO_STRICT_REGEX + case BACKSL|'}': +#endif SETERROR(REG_EPAREN); break; case BACKSL|'1':