aboutsummaryrefslogtreecommitdiff
path: root/posix/regcomp.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-01-14 01:45:37 +0000
committerUlrich Drepper <drepper@redhat.com>2004-01-14 01:45:37 +0000
commit294b6bcc13c28fe4b4d605a9f8e3cab58e6853ca (patch)
tree0b9a617357049d60273de6ba5210ec4363c2b085 /posix/regcomp.c
parent81144a9c4e2ef74f2e935192db562684793a4da9 (diff)
downloadglibc-294b6bcc13c28fe4b4d605a9f8e3cab58e6853ca.tar
glibc-294b6bcc13c28fe4b4d605a9f8e3cab58e6853ca.tar.gz
glibc-294b6bcc13c28fe4b4d605a9f8e3cab58e6853ca.tar.bz2
glibc-294b6bcc13c28fe4b4d605a9f8e3cab58e6853ca.zip
Update.
2004-01-14 Jakub Jelinek <jakub@redhat.com> * posix/regcomp.c (peek_token_bracket): Check remaining string length before re_string_peek_byte (x, 1). (parse_bracket_symbol): Likewise. * posix/regex_internal.h (re_string_is_single_byte_char): Return true at last byte in the string. * posix/bug-regex22.c (main): Add new test.
Diffstat (limited to 'posix/regcomp.c')
-rw-r--r--posix/regcomp.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/posix/regcomp.c b/posix/regcomp.c
index 6b4af54da8..adb9d04d8a 100644
--- a/posix/regcomp.c
+++ b/posix/regcomp.c
@@ -1881,7 +1881,8 @@ peek_token_bracket (token, input, syntax)
}
#endif /* RE_ENABLE_I18N */
- if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS))
+ if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS)
+ && re_string_cur_idx (input) + 1 < re_string_length (input))
{
/* In this case, '\' escape a character. */
unsigned char c2;
@@ -1895,7 +1896,10 @@ peek_token_bracket (token, input, syntax)
{
unsigned char c2;
int token_len;
- c2 = re_string_peek_byte (input, 1);
+ if (re_string_cur_idx (input) + 1 < re_string_length (input))
+ c2 = re_string_peek_byte (input, 1);
+ else
+ c2 = 0;
token->opr.c = c2;
token_len = 2;
switch (c2)
@@ -3268,14 +3272,18 @@ parse_bracket_symbol (elem, regexp, token)
{
unsigned char ch, delim = token->opr.c;
int i = 0;
+ if (re_string_eoi(regexp))
+ return REG_EBRACK;
for (;; ++i)
{
- if (re_string_eoi(regexp) || i >= BRACKET_NAME_BUF_SIZE)
+ if (i >= BRACKET_NAME_BUF_SIZE)
return REG_EBRACK;
if (token->type == OP_OPEN_CHAR_CLASS)
ch = re_string_fetch_byte_case (regexp);
else
ch = re_string_fetch_byte (regexp);
+ if (re_string_eoi(regexp))
+ return REG_EBRACK;
if (ch == delim && re_string_peek_byte (regexp, 0) == ']')
break;
elem->opr.name[i] = ch;