diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2023-04-21 04:51:47 +0200 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2023-04-21 04:51:47 +0200 |
commit | 762b7d07eaa82d7f20a6778726e589c809fbe58e (patch) | |
tree | 896f550653f1f4c0087938f0c5bbe2d06a69b763 | |
parent | scd,p15: Enforce a min. PIN length for certain cards. (diff) | |
download | gnupg2-762b7d07eaa82d7f20a6778726e589c809fbe58e.tar.xz gnupg2-762b7d07eaa82d7f20a6778726e589c809fbe58e.zip |
common: Incorporate upstream changes of regexp.
* regexp/jimregexp.c (regatom): Raise REG_ERR_UNMATCHED_BRACKET when
no matching end bracket.
(regmatch): Fix the end of word check.
--
Original changes:
Signed-off-by: Steve Bennett <steveb@workware.net.au>
GnuPG-bug-id: 6455
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
-rw-r--r-- | regexp/jimregexp.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/regexp/jimregexp.c b/regexp/jimregexp.c index 91be38f22..d80eabd8e 100644 --- a/regexp/jimregexp.c +++ b/regexp/jimregexp.c @@ -795,8 +795,11 @@ static int regatom(regex_t *preg, int *flagp) for (cc = 0; cc < CC_NUM; cc++) { n = strlen(character_class[cc]); - if (!strncmp(pattern, character_class[cc], n) - && pattern[n] == ']') { + if (strncmp(pattern, character_class[cc], n) == 0) { + if (pattern[n] != ']') { + preg->err = REG_ERR_UNMATCHED_BRACKET; + return 0; + } /* Found a character class */ pattern += n + 1; break; @@ -1508,7 +1511,7 @@ static int regmatch(regex_t *preg, int prog) /* Can't match at BOL */ if (preg->reginput > preg->regbol) { /* Current must be EOL or nonword */ - if (reg_iseol(preg, c) || !isalnum(UCHAR(c)) || c != '_') { + if (reg_iseol(preg, c) || !(isalnum(UCHAR(c)) || c == '_')) { c = preg->reginput[-1]; /* Previous must be word */ if (isalnum(UCHAR(c)) || c == '_') { |