GNU bug report logs -
#11453
`ls` in coreutils-8.17 incorrectly shows broken symlinks in /
Previous Next
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
Jim Meyering wrote:
> 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);
Humph. That's wrong, too.
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.