This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 2/1][BZ #866] glob() should match dangling symlinks.
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: glibc at tomlee dot co
- Cc: libc-alpha at sourceware dot org
- Date: Sat, 12 Oct 2013 10:25:29 +0200
- Subject: [PATCH 2/1][BZ #866] glob() should match dangling symlinks.
- Authentication-results: sourceware.org; auth=none
- References: <20131003075937 dot GA22576 at domone dot podge>
Hi,
This is another bug in glob with patch in bugzilla from Tom Lee ready,
see https://sourceware.org/bugzilla/show_bug.cgi?id=866
Patch itself is ok, what is left is decide if listing dangling symlinks
is desired behavior.
Comments?
* posix/glob.c: Match dangling symlinks.
diff --git a/posix/glob.c b/posix/glob.c
index 87d4f1b..64677aa 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -204,7 +204,7 @@ static const char *next_brace_sub (const char *begin, int flags) __THROW;
static int glob_in_dir (const char *pattern, const char *directory,
int flags, int (*errfunc) (const char *, int),
- glob_t *pglob, size_t alloca_used);
+ glob_t *pglob, size_t alloca_used, int chklnks);
extern int __glob_pattern_type (const char *pattern, int quote)
attribute_hidden;
@@ -1078,7 +1078,7 @@ glob (pattern, flags, errfunc, pglob)
status = glob_in_dir (filename, dirs.gl_pathv[i],
((flags | GLOB_APPEND)
& ~(GLOB_NOCHECK | GLOB_NOMAGIC)),
- errfunc, pglob, alloca_used);
+ errfunc, pglob, alloca_used, 1);
if (status == GLOB_NOMATCH)
/* No matches in this directory. Try the next. */
continue;
@@ -1185,7 +1185,7 @@ glob (pattern, flags, errfunc, pglob)
if (dirname_modified)
flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC);
status = glob_in_dir (filename, dirname, flags, errfunc, pglob,
- alloca_used);
+ alloca_used, 0);
if (status != 0)
{
if (status == GLOB_NOMATCH && flags != orig_flags
@@ -1462,7 +1462,7 @@ link_exists2_p (const char *dir, size_t dirlen, const char *fname,
static int
glob_in_dir (const char *pattern, const char *directory, int flags,
int (*errfunc) (const char *, int),
- glob_t *pglob, size_t alloca_used)
+ glob_t *pglob, size_t alloca_used, int chklnks)
{
size_t dirlen = strlen (directory);
void *stream = NULL;
@@ -1605,8 +1605,8 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
/* If the file we found is a symlink we have to
make sure the target file exists. */
if (!DIRENT_MIGHT_BE_SYMLINK (d)
- || link_exists_p (dfd, directory, dirlen, name, pglob,
- flags))
+ || (chklnks ? link_exists_p (dfd, directory, dirlen, name, pglob,
+ flags) : 1))
{
if (cur == names->count)
{