Bug 22513

Summary: If patterns has a trailing slash then glob has to match directories only
Product: glibc Reporter: Dmitry Goncharov <dgoncharov>
Component: globAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: fweimer
Priority: P2 Flags: fweimer: security-
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Project(s) to access: ssh public key:

Description Dmitry Goncharov 2017-11-28 21:03:43 UTC
If patterns has a trailing slash then glob has to match directories only.

http://pubs.opengroup.org/onlinepubs/9699919799/.

Here posix specifies
"An ordinary character is a pattern that shall match itself. It can be any character in the supported character set except for NUL, those special shell characters in Quoting that require quoting, and the following three special pattern characters."

If the pattern is only 2 characters long (e.g. */) glob already matches directories only. If the pattern is longer e.g. hello*/ then glob matches only directories or files and directoires depending on type in readdir_result.
Comment 1 Florian Weimer 2018-10-04 17:35:40 UTC
Fixed in glibc 2.19.

*** This bug has been marked as a duplicate of bug 10278 ***