This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] posix: if glob has a trailing slash match directories only.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]