From owner-freebsd-bugs@freebsd.org Sat Dec 12 06:07:16 2020 Return-Path: Delivered-To: freebsd-bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 818734A96EF for ; Sat, 12 Dec 2020 06:07:16 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 4CtHHS361kz4TmK for ; Sat, 12 Dec 2020 06:07:16 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 6A8484A96EE; Sat, 12 Dec 2020 06:07:16 +0000 (UTC) Delivered-To: bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6A4BC4A9861 for ; Sat, 12 Dec 2020 06:07:16 +0000 (UTC) (envelope-from bugzilla-noreply@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CtHHS2WcJz4TXB for ; Sat, 12 Dec 2020 06:07:16 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 4901518715 for ; Sat, 12 Dec 2020 06:07:16 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 0BC67GfC046792 for ; Sat, 12 Dec 2020 06:07:16 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 0BC67GlG046791 for bugs@FreeBSD.org; Sat, 12 Dec 2020 06:07:16 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 251775] bsdgrep: egrep regards '{foo}' as invalid regular expression Date: Sat, 12 Dec 2020 06:07:16 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: yasu@utahime.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter cc Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Dec 2020 06:07:16 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D251775 Bug ID: 251775 Summary: bsdgrep: egrep regards '{foo}' as invalid regular expression Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: yasu@utahime.org CC: kevans@freebsd.org I'm the maintainer of security/logcheck port. It detects log messages that should be reported by applying regular expressions to each messages with eg= rep. After grep is switched to bsdgrep on 13-CURRENT I noticed logcheck produces some errors caused by egrep. I investigate them and found most of them happ= ens because regular expressions are invalid according to the definition on re_format(7). But I also found there is one case that caused by bug of bsdg= rep. In re_format(7) 'bound' is defined as following. "A bound is '{' followed by an unsigned decimal integer, possibly followed = by ',' possibly followed by another unsigned decimal integer, always followed = by '}'. The integers must lie between 0 and RE_DUP_MAX (255) inclusive, and if there are two of them, the first may not exceed the second." And there is also following clarification. " A '{' followed by a character other than a digit is an ordinary character, not the beginning of a bound. " So '{100}' is regarded as bound and therefore is invalid as regular express= ion. But '{foo}' isn't regarded as bound. Hence it's a valid regular expression = and matches itself. Gnugrep's egrep works fine with this regular expression. ---------------------------------------------------------------------- yasu@eastasia[1575]% uname -U 1202000 yasu@eastasia[1614]% type egrep egrep is /usr/bin/egrep yasu@eastasia[1615]% egrep --version egrep (GNU grep) 2.5.1-FreeBSD Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. yasu@eastasia[1616]% echo '{foo}' | egrep '{foo}' {foo} yasu@eastasia[1617]% ---------------------------------------------------------------------- But bsdgrep's egrep results in error. ---------------------------------------------------------------------- yasu@rolling-vm-freebsd1[1135]% uname -U 1300131 yasu@rolling-vm-freebsd1[1142]% type egrep egrep is /usr/bin/egrep yasu@rolling-vm-freebsd1[1143]% egrep --version egrep (BSD grep, GNU compatible) 2.6.0-FreeBSD yasu@rolling-vm-freebsd1[1144]% echo '{foo}' | egrep '{foo}' egrep: repetition-operator operand invalid yasu@rolling-vm-freebsd1[1145]% ---------------------------------------------------------------------- --=20 You are receiving this mail because: You are the assignee for the bug.=