summaryrefslogtreecommitdiffstats
path: root/usr.bin/grep
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2016-03-13 14:53:12 +0000
committerian <ian@FreeBSD.org>2016-03-13 14:53:12 +0000
commit5d2092c908f0a7d5e3de057b88a882b586634cc5 (patch)
tree512e1001535bfa2939d4aa699a4b0a46580fa306 /usr.bin/grep
parentf291714326a254d61e9dc1458f3b103faab9b394 (diff)
downloadFreeBSD-src-5d2092c908f0a7d5e3de057b88a882b586634cc5.zip
FreeBSD-src-5d2092c908f0a7d5e3de057b88a882b586634cc5.tar.gz
Fix a bug in bsdgrep that caused the program to hang in a tight loop for
some combinations of command line options and search patterns. The code was examining regexec flags looking for a regcomp flag value. The fix is to look in the struct field where the decoded regcomp flag was stored when the regex was compiled. With this fix, it's possible to build WITHOUT_GNU_GREP_COMPAT and WITH_BSDGREP and have a usable GPL-free grep (which of course lacks gnugrep extensions). It now passes the kyua tests except for one test that requires the -z/--null-data gnu extension, and one test involving outputting context lines across multiple files which appears to sometimes output an extra delimiter line ("--") between matches (a rather obscure failure of a rather obscure feature, so bsdgrep should be generally usable now).
Diffstat (limited to 'usr.bin/grep')
-rw-r--r--usr.bin/grep/regex/glue.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/usr.bin/grep/regex/glue.h b/usr.bin/grep/regex/glue.h
index 2fea4fd..0c54e98 100644
--- a/usr.bin/grep/regex/glue.h
+++ b/usr.bin/grep/regex/glue.h
@@ -50,7 +50,7 @@ typedef enum { STR_WIDE, STR_BYTE, STR_MBS, STR_USER } tre_str_type_t;
if ((long long)pmatch[0].rm_eo - pmatch[0].rm_so < 0) \
return REG_NOMATCH; \
ret = fn; \
- for (unsigned i = 0; (!(eflags & REG_NOSUB) && (i < nmatch)); i++)\
+ for (unsigned i = 0; (!preg->nosub && (i < nmatch)); i++) \
{ \
pmatch[i].rm_so += offset; \
pmatch[i].rm_eo += offset; \
OpenPOWER on IntegriCloud