This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] posix: if glob has a trailing slash match directories only.
- From: Dmitry Goncharov <dgoncharov at users dot sf dot net>
- To: libc-alpha at sourceware dot org
- Date: Tue, 28 Nov 2017 23:21:15 -0500
- Subject: Re: [PATCH] posix: if glob has a trailing slash match directories only.
- Authentication-results: sourceware.org; auth=none
- References: <20171128210857.GC2745@madrid> <a97c9749-5bcd-0292-9eae-bd7c4c59ab09@cs.ucla.edu>
On Tue, Nov 28, 2017 at 05:58:12PM -0800, Paul Eggert wrote:
> On 11/28/2017 01:08 PM, Dmitry Goncharov wrote:
> > If pattern has a trailing slash match directories only.
> > This patch fixes [BZ #22513].
>
> I do not observe the bug on Fedora 27, which uses glibc 2.26-16, so
> presumably this bug was introduced in the recent merges from Gnulib.
> However, I not observe the bug with Gnulib master lib/glob.c either.
> Could you explain what introduced the bug, e.g., by isolating the Glibc
> commit that introduced it? Perhaps we botched the merge, and if so we
> should fix the botch rather than work around the bug with some extra code.
>
commit 1cab5444231a4a1fab9c3abb107d22af4eb09327 (tag: cvs/libc-ud-971031)
Author: Ulrich Drepper <drepper@redhat.com>
Date: Fri Oct 31 22:55:02 1997 +0000
introduced the following piece of code among others
+#ifdef HAVE_D_TYPE
+ /* If we shall match only directories use the information
+ provided by the dirent if possible. */
+ if ((flags & GLOB_ONLYDIR)
+ && d->d_type != DT_UNKNOWN && d->d_type != DT_DIR)
+ continue;
+#endif
+
if (fnmatch (pattern, name,
(!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) |
((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)
As long as your filesystem initializes d->d_type you won't see the issue.
When d->d_type is DT_UNKNOWN then d may not be a directory.
regards, Dmitry