This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
swbz #23501 - define stat buffer for FTW_SLN case
- From: DJ Delorie <dj at redhat dot com>
- To: libc-alpha at sourceware dot org
- Date: Fri, 16 Nov 2018 01:03:29 -0500
- Subject: swbz #23501 - define stat buffer for FTW_SLN case
http://austingroupbugs.net/view.php?id=1121
https://sourceware.org/bugzilla/show_bug.cgi?id=23501
Tested with no regressions.
* io/ftw.c (process_entry): Define the stat buf in the case of
dangling symlinks, despite FTW_PHYS flag.
diff --git a/io/ftw.c b/io/ftw.c
index f6ecbe7d90..ac2e38333b 100644
--- a/io/ftw.c
+++ b/io/ftw.c
@@ -424,7 +424,19 @@ process_entry (struct ftw_data *data, struct dir_data *dir, const char *name,
else if (data->flags & FTW_PHYS)
flag = FTW_NS;
else if (d_type == DT_LNK)
- flag = FTW_SLN;
+ {
+ flag = FTW_SLN;
+
+ /* We don't care about any errors that occur here. Old code
+ left ST undefined; a clarification at the ISO level
+ defines it for this case, and filling in ST is all we
+ need, so this is only "best effort". */
+ if (dir->streamfd != -1)
+ FXSTATAT (_STAT_VER, dir->streamfd, name, &st,
+ AT_SYMLINK_NOFOLLOW);
+ else
+ LXSTAT (_STAT_VER, name, &st);
+ }
else
{
if (dir->streamfd != -1)