public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "splite-glibc at sigint dot cs dot purdue dot edu" <sourceware-bugzilla@sources.redhat.com>
To: glibc-bugs@sources.redhat.com
Subject: [Bug libc/866] New: glob should match dangling symlinks
Date: Fri, 22 Apr 2005 19:50:00 -0000	[thread overview]
Message-ID: <20050422195020.866.splite-glibc@sigint.cs.purdue.edu> (raw)

The 1.53 revision to sysdeps/generic/glob.c added a check for dangling symlinks.
 While necessary for directory globs, it still seems desirable to match dangling
symlinks in filename globs, as bash and tcsh's built-in globbers do.  This
program demonstrates the problem:

% cat globtest.c
#include <stdio.h>
#include <glob.h>

main()
{
        int i;
        glob_t pglob;

        chdir("/tmp");
        symlink("/nope", "foo1");
        symlink("/usr", "foo2");
        glob("foo[12]", 0, 0, &pglob);
        for (i = 0; i < pglob.gl_pathc; i++)
                printf("pglob.gl_pathv[%d] = \"%s\"\n", i, pglob.gl_pathv[i]);
        unlink("foo1");
        unlink("foo2");
}
% gcc -o globtest globtest.c
% ./globtest
pglob.gl_pathv[0] = "foo2"


Same thing in bash (tcsh behaves identically):

bash-2.05b$ cd /tmp
bash-2.05b$ ln -s /nope foo1
bash-2.05b$ ln -s /usr foo2
bash-2.05b$ echo foo[12]
foo1 foo2
bash-2.05b$ rm foo1 foo2


I'm attaching a patch to glob.c that makes glob()'s behavior mimic bash and
tcsh's.  The resulting glob() still passes globtest.sh, so it seems correct.

-- 
           Summary: glob should match dangling symlinks
           Product: glibc
           Version: 2.3.5
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: gotom at debian dot or dot jp
        ReportedBy: splite-glibc at sigint dot cs dot purdue dot edu
                CC: glibc-bugs at sources dot redhat dot com,splite-glibc at
                    sigint dot cs dot purdue dot edu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://sources.redhat.com/bugzilla/show_bug.cgi?id=866

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


             reply	other threads:[~2005-04-22 19:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-22 19:50 splite-glibc at sigint dot cs dot purdue dot edu [this message]
2005-04-22 19:54 ` [Bug libc/866] " splite-glibc at sigint dot cs dot purdue dot edu
2005-09-27  5:54 ` drepper at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050422195020.866.splite-glibc@sigint.cs.purdue.edu \
    --to=sourceware-bugzilla@sources.redhat.com \
    --cc=glibc-bugs@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).