Date: Sat, 12 Dec 2020 06:07:16 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 251775] bsdgrep: egrep regards '{foo}' as invalid regular expression Message-ID: <bug-251775-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
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.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-251775-227>