main/musl: fix glob regression

likely fixes #8009
This commit is contained in:
Timo Teräs 2017-10-28 11:51:12 +03:00
parent 270482be20
commit 39bfeece25
2 changed files with 47 additions and 2 deletions

View File

@ -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

View File

@ -2,7 +2,7 @@
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=musl
pkgver=1.1.17
pkgrel=1
pkgrel=2
pkgdesc="the musl c library (libc) implementation"
url="http://www.musl-libc.org/"
arch="all"
@ -17,8 +17,8 @@ nolibc) ;;
*) subpackages="$subpackages $pkgname-utils";;
esac
source="http://www.musl-libc.org/releases/musl-$pkgver.tar.gz
0001-posix_spawn-use-larger-stack-to-cover-worst-case-in-.patch
0002-fix-regression-in-glob-with-literal-.-or-.-path-comp.patch
1000-implement-strftime-GNU-extension-padding-specifiers-.patch
2000-pthread-internals-increase-DEFAULT_GUARD_SIZE-to-2-p.patch
3002-stdio-implement-fopencookie-3.patch
@ -146,6 +146,7 @@ compat() {
sha512sums="bc99c7d58d64116c03e68fe77141a1f2938e0c01ba027937587a060d435b4b00b8b1f18c63fb8ed445ef36f377974e02a7b4821c793e4292041e31e66f145428 musl-1.1.17.tar.gz
0ccf3dc82ab5556c001a0cc4209f4263eb3670f188e1ca0e649593f4dca0bd1107f1985f608b30c4eb0ef8b0a76d31434fb9ecc3c82fed2bb5f1860016d5057c 0001-posix_spawn-use-larger-stack-to-cover-worst-case-in-.patch
3e03977cacd24434aefba5f457a96d956f4264f2e53197a1616d11d52d65884e0411fc2395c6ffaec4ca4b21da3563327b1823169391f53a8d137f8202f88b38 0002-fix-regression-in-glob-with-literal-.-or-.-path-comp.patch
7e4c703e57a3564cd3ee1d5334b806cbe654355179ba55d4d25361dfc555eb4a7d081d80d64fdaff8476949afd04558d278b124d1fb108080beaa5ba2f8ce2b9 1000-implement-strftime-GNU-extension-padding-specifiers-.patch
2c8e1dde1834238097b2ee8a7bfb53471a0d9cff4a5e38b55f048b567deff1cdd47c170d0578a67b1a039f95a6c5fbb8cff369c75b6a3e4d7ed171e8e86ebb8c 2000-pthread-internals-increase-DEFAULT_GUARD_SIZE-to-2-p.patch
0053e16cbac968b50dee98e3b36d29a497aaca6d9d0e120556273c9d0cd8360310eb7b7ab3c1e416217210fdd071e98268eaca54f3a0e9a22408ed8701dc54c1 3002-stdio-implement-fopencookie-3.patch