summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc/port/regex/regcomp.c
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2017-08-15 12:08:39 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2017-08-15 12:08:39 +0000
commit3c7233becda2b705220673be1e9fd921b4ef9c3e (patch)
treea2a2d1889108f303966b2d673fb8c025a36a4a63 /usr/src/lib/libc/port/regex/regcomp.c
parent6ce9515e507bc9c47fd127589ef8734a84fed1c3 (diff)
parent63efadf0294ce893234c3c9a9cb712b1f9929fdf (diff)
downloadillumos-joyent-3c7233becda2b705220673be1e9fd921b4ef9c3e.tar.gz
[illumos-gate merge]
commit 79d022da827bda94f470706ea9a9a8d6dbab9d07 8568 fnmatch, glob: fix exponential CPU use with repeated '*' operators commit 02e2c3ed584d6e282e2f2f9ed1659ef2ba09b924 8575 regcomp(3C): handle invalid {} constructs consistently
Diffstat (limited to 'usr/src/lib/libc/port/regex/regcomp.c')
-rw-r--r--usr/src/lib/libc/port/regex/regcomp.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/usr/src/lib/libc/port/regex/regcomp.c b/usr/src/lib/libc/port/regex/regcomp.c
index c1c1ce90a3..3bd27129a0 100644
--- a/usr/src/lib/libc/port/regex/regcomp.c
+++ b/usr/src/lib/libc/port/regex/regcomp.c
@@ -396,6 +396,7 @@ p_ere_exp(struct parse *p)
case '*':
case '+':
case '?':
+ case '{':
SETERROR(REG_BADRPT);
break;
case '.':
@@ -422,9 +423,6 @@ p_ere_exp(struct parse *p)
break;
}
break;
- case '{': /* okay as ordinary except if digit follows */
- (void) REQUIRE(!MORE() || !isdigit((uch)PEEK()), REG_BADRPT);
- /* FALLTHROUGH */
default:
if (p->error != 0)
return;
@@ -438,9 +436,11 @@ p_ere_exp(struct parse *p)
return;
c = PEEK();
/* we call { a repetition if followed by a digit */
- if (!(c == '*' || c == '+' || c == '?' ||
- (c == '{' && MORE2() && isdigit((uch)PEEK2()))))
+ if (!(c == '*' || c == '+' || c == '?' || c == '{'))
return; /* no repetition, we're done */
+ else if (c == '{')
+ (void) REQUIRE(MORE2() && \
+ (isdigit((uch)PEEK2()) || PEEK2() == ','), REG_BADRPT);
NEXT();
(void) REQUIRE(!wascaret, REG_BADRPT);
@@ -601,7 +601,6 @@ p_simp_re(struct parse *p,
(void) REQUIRE(EATTWO('\\', ')'), REG_EPAREN);
break;
case BACKSL|')': /* should not get here -- must be user */
- case BACKSL|'}':
SETERROR(REG_EPAREN);
break;
case BACKSL|'1':