From 6614b6b619ff210305cbd81b64f48af085381cdf Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 18 Jan 2000 09:36:26 +0000 Subject: [PATCH] (regex_compile): Return appropriate errors for unterminated brace expressions. Detect invalid characters in brace expressions. --- posix/regex.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/posix/regex.c b/posix/regex.c index 04df21e3081..84793cec942 100644 --- a/posix/regex.c +++ b/posix/regex.c @@ -2,7 +2,7 @@ version 0.12. (Implements POSIX draft P1003.2/D11.2, except for some of the internationalization features.) - Copyright (C) 1993, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc. + Copyright (C) 1993-1999, 2000 Free Software Foundation, Inc. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as @@ -2619,7 +2619,7 @@ regex_compile (pattern, size, syntax, bufp) if (p == pend) { - if (syntax & RE_NO_BK_BRACES) + if (!(syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) goto unfetch_interval; else FREE_STACK_RETURN (REG_EBRACE); @@ -2630,7 +2630,12 @@ regex_compile (pattern, size, syntax, bufp) if (c == ',') { GET_UNSIGNED_NUMBER (upper_bound); - if (upper_bound < 0) upper_bound = RE_DUP_MAX; + if ((!(syntax & RE_NO_BK_BRACES) && c != '\\') + || ((syntax & RE_NO_BK_BRACES) && c != '}')) + FREE_STACK_RETURN (REG_BADBR); + + if (upper_bound < 0) + upper_bound = RE_DUP_MAX; } else /* Interval such as `{1}' => match exactly once. */ @@ -2639,7 +2644,7 @@ regex_compile (pattern, size, syntax, bufp) if (lower_bound < 0 || upper_bound > RE_DUP_MAX || lower_bound > upper_bound) { - if (syntax & RE_NO_BK_BRACES) + if (!(syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) goto unfetch_interval; else FREE_STACK_RETURN (REG_BADBR); @@ -2654,7 +2659,7 @@ regex_compile (pattern, size, syntax, bufp) if (c != '}') { - if (syntax & RE_NO_BK_BRACES) + if (!(syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) goto unfetch_interval; else FREE_STACK_RETURN (REG_BADBR); -- 2.47.2