summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc/port/regex/regcomp.c
diff options
context:
space:
mode:
authorYuri Pankov <yuri.pankov@nexenta.com>2017-08-11 23:51:17 +0300
committerDan McDonald <danmcd@joyent.com>2017-08-14 11:10:13 -0400
commit02e2c3ed584d6e282e2f2f9ed1659ef2ba09b924 (patch)
tree7c50f78d628f40e87eca2f2edfc7cfbdc1ba5a50 /usr/src/lib/libc/port/regex/regcomp.c
parent5e9f42abf61392dc608a661563fb49e7707f0478 (diff)
downloadillumos-gate-02e2c3ed584d6e282e2f2f9ed1659ef2ba09b924.tar.gz
8575 regcomp(3C): handle invalid {} constructs consistently
Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Toomas Soome <tsoome@me.com> Approved by: Dan McDonald <danmcd@joyent.com>
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':