GNU bug report logs - #11453
`ls` in coreutils-8.17 incorrectly shows broken symlinks in /

Previous Next

Package: coreutils;

Reported by: Mike Frysinger <vapier <at> gentoo.org>

Date: Fri, 11 May 2012 18:13:01 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Jim Meyering <jim <at> meyering.net>
To: Mike Frysinger <vapier <at> gentoo.org>
Cc: 11453 <at> debbugs.gnu.org
Subject: bug#11453: `ls` in coreutils-8.17 incorrectly shows broken symlinks in /
Date: Fri, 11 May 2012 20:48:33 +0200
Mike Frysinger wrote:
> coreutils-8.16 works fine (confirmed), and i don't recall seeing this bug
> before, so looks like a regression with 8.17
>
> easy to show:
> $ sudo ln -s dev /foo
> $ ls --color=auto /
> ... foo wrongly shows up in blinky text indicating it's a broken symlink ...
> $ ls --color=auto /.
> ... foo correctly shows up with normal coloring indicating it's a symlink ...
> $ cd / ; ls --color=auto
> ... foo correctly shows up with normal coloring indicating it's a symlink ...
> -mike

Rats.
That bug was introduced by my clean-up.
Here's the probable fix.
Thanks for the report!

diff --git a/src/ls.c b/src/ls.c
index 397e4ea..b548382 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -3213,7 +3213,8 @@ make_link_name (char const *name, char const *linkname)
     return xstrdup (linkname);

   char *p = xmalloc (prefix_len + 1 + strlen (linkname) + 1);
-  stpcpy (stpncpy (p, name, prefix_len + 1), linkname);
+  bool prefix_ends_in_slash = ISSLASH (name[prefix_len - 1]);
+  stpcpy (stpncpy (p, name, prefix_len + !prefix_ends_in_slash), linkname);
   return p;
 }




This bug report was last modified 13 years and 70 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.