aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2023-04-20 10:26:40 +0000
committerWerner Koch <[email protected]>2023-04-20 10:28:09 +0000
commit3ad4b339b886bdab86df96d4c4a7c100c51ee971 (patch)
treed984afe83ea7be5b460538fd325bf7a492766d9f
parentpo: Fix in German translation (diff)
downloadgnupg-3ad4b339b886bdab86df96d4c4a7c100c51ee971.tar.gz
gnupg-3ad4b339b886bdab86df96d4c4a7c100c51ee971.zip
common: Fix minor bug in the jimregexp code.
* regexp/jimregexp.c (regatom): Make error checking for stray backslash at end of the string work. Check that the pattern class is closed by a bracket. -- GnuPG-bug-id: 6455 Co-authored-by: Guldrelokk
-rw-r--r--regexp/jimregexp.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/regexp/jimregexp.c b/regexp/jimregexp.c
index 7fd6d473e..91be38f22 100644
--- a/regexp/jimregexp.c
+++ b/regexp/jimregexp.c
@@ -778,7 +778,7 @@ static int regatom(regex_t *preg, int *flagp)
preg->err = REG_ERR_NULL_CHAR;
return 0;
}
- if (start == '\\' && *pattern == 0) {
+ if (end == '\\' && *pattern == 0) {
preg->err = REG_ERR_INVALID_ESCAPE;
return 0;
}
@@ -795,7 +795,8 @@ 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) == 0) {
+ if (!strncmp(pattern, character_class[cc], n)
+ && pattern[n] == ']') {
/* Found a character class */
pattern += n + 1;
break;