summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2017-09-06 21:59:22 -0400
committerRich Felker <dalias@aerifal.cx>2017-09-06 21:59:22 -0400
commit8c4be3e2209d2a1d3874b8bc2b474668fcbbbac6 (patch)
tree6b0a0cb282c6a00bf244d87277568f138f6d7164
parent565dbee24d4bf55728be1c274fca1e7f3196fd73 (diff)
downloadmusl-8c4be3e2209d2a1d3874b8bc2b474668fcbbbac6.tar.gz
fix glob descent into . and .. with GLOB_PERIOD
GLOB_PERIOD is a gnu extension, and GNU glob does not seem to honor it except in the last path component. it's not clear whether this a bug or intentional, but it seems reasonable that it should exclude the special entries . and .. when walking. changes based on report and analysis by Julien Ramseier.
-rw-r--r--src/regex/glob.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/regex/glob.c b/src/regex/glob.c
index 2d4d562e..6f8425ca 100644
--- a/src/regex/glob.c
+++ b/src/regex/glob.c
@@ -100,6 +100,10 @@ static int match_in_dir(const char *d, const char *p, int flags, int (*errfunc)(
continue;
if (p2 && de->d_type && !S_ISDIR(de->d_type<<12) && !S_ISLNK(de->d_type<<12))
continue;
+ if (p2 && de->d_name[0]=='.' && !de->d_name[1])
+ continue;
+ if (p2 && de->d_name[0]=='.' && de->d_name[1]=='.' && !de->d_name[2])
+ continue;
if (*d) {
memcpy(name, d, l);
name[l] = '/';