swbz #23501 - define stat buffer for FTW_SLN case

DJ Delorie dj@redhat.com
Fri Nov 16 06:03:00 GMT 2018


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)



More information about the Libc-alpha mailing list