Skip to content
Snippets Groups Projects
Commit ad092191 authored by Herbert Xu's avatar Herbert Xu
Browse files

expand - Fix dangling left square brackets in patterns


When there is an unmatched left square bracket in patterns, pmatch
will behave strangely and exhibit undefined behaviour.  This patch
(based on Harld van Dijk's original) fixes this by treating it as
a literal left square bracket.

Reported-by: default avatarOlof Johansson <olof@ethup.se>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 4cf38c1c
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -1584,14 +1584,14 @@ pmatch(const char *pattern, const char *string)
p++;
}
found = 0;
chr = *q++;
chr = *q;
if (chr == '\0')
return 0;
c = *p++;
do {
if (!c) {
p = startp;
c = *p;
c = '[';
goto dft;
}
if (c == '[') {
Loading
Loading
@@ -1618,6 +1618,7 @@ pmatch(const char *pattern, const char *string)
} while ((c = *p++) != ']');
if (found == invert)
return 0;
q++;
break;
}
dft: default:
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment