aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl/0002-fix-regression-in-glob-with-literal-.-or-.-path-comp.patch
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2017-10-28 11:51:12 +0300
committerTimo Teräs <timo.teras@iki.fi>2017-10-28 11:59:50 +0300
commit39bfeece257a70de085fbbadf918fa26d3812212 (patch)
treeba6f1ba83b71fa97694e76e1044c0f9029bd0577 /main/musl/0002-fix-regression-in-glob-with-literal-.-or-.-path-comp.patch
parent270482be202256d47c16aa0f16f87fe3f205d458 (diff)
downloadaports-39bfeece257a70de085fbbadf918fa26d3812212.tar.bz2
aports-39bfeece257a70de085fbbadf918fa26d3812212.tar.xz
main/musl: fix glob regression
likely fixes #8009
Diffstat (limited to 'main/musl/0002-fix-regression-in-glob-with-literal-.-or-.-path-comp.patch')
-rw-r--r--main/musl/0002-fix-regression-in-glob-with-literal-.-or-.-path-comp.patch44
1 files changed, 44 insertions, 0 deletions
diff --git a/main/musl/0002-fix-regression-in-glob-with-literal-.-or-.-path-comp.patch b/main/musl/0002-fix-regression-in-glob-with-literal-.-or-.-path-comp.patch
new file mode 100644
index 0000000000..d7ea51e11d
--- /dev/null
+++ b/main/musl/0002-fix-regression-in-glob-with-literal-.-or-.-path-comp.patch
@@ -0,0 +1,44 @@
+From ec04d122f1182aeb91f39b0e80ae40c68e4d9605 Mon Sep 17 00:00:00 2001
+From: Rich Felker <dalias@aerifal.cx>
+Date: Sat, 21 Oct 2017 12:17:49 -0400
+Subject: [PATCH] fix regression in glob with literal . or .. path component
+
+commit 8c4be3e2209d2a1d3874b8bc2b474668fcbbbac6 was written to
+preclude the GLOB_PERIOD extension from matching these directory
+entries, but also precluded literal matches.
+
+adjust the check that excludes . and .. to check whether the
+GLOB_PERIOD flag is in effect, so that it cannot alter behavior in
+cases governed by the standard, and also don't exclude . or .. in any
+case where normal glob behavior (fnmatch's FNM_PERIOD flag) would have
+included one or both of them (patterns such as ".*").
+
+it's still not clear whether this is the preferred behavior for
+GLOB_PERIOD, but at least it's clear that it can no longer break
+applications which are not relying on quirks of a nonstandard feature.
+---
+ src/regex/glob.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/src/regex/glob.c b/src/regex/glob.c
+index 6f8425ca..85671985 100644
+--- a/src/regex/glob.c
++++ b/src/regex/glob.c
+@@ -100,9 +100,11 @@ 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])
++ /* With GLOB_PERIOD, don't allow matching . or .. unless
++ * fnmatch would match them with FNM_PERIOD rules in effect. */
++ if (p2 && (flags & GLOB_PERIOD) && de->d_name[0]=='.'
++ && (!de->d_name[1] || de->d_name[1]=='.' && !de->d_name[2])
++ && fnmatch(p, de->d_name, fnm_flags | FNM_PERIOD))
+ continue;
+ if (*d) {
+ memcpy(name, d, l);
+--
+2.14.3
+