File reproducible.patch of Package glibc

Index: glibc-2.28/elf/ldconfig.c
===================================================================
--- glibc-2.28.orig/elf/ldconfig.c
+++ glibc-2.28/elf/ldconfig.c
@@ -695,8 +695,9 @@ search_dir (const struct dir_entry *entr
       real_file_name = file_name;
     }
 
-  DIR *dir;
-  if (dir_name == NULL || (dir = opendir (dir_name)) == NULL)
+  int dirn;
+  struct dirent64 **namelist;
+  if (dir_name == NULL || (dirn = scandir64 (dir_name, &namelist, NULL, alphasort64)) == -1)
     {
       if (opt_verbose)
 	error (0, errno, _("Can't open directory %s"), entry->path);
@@ -705,10 +706,10 @@ search_dir (const struct dir_entry *entr
       return;
     }
 
-  struct dirent64 *direntry;
   struct dlib_entry *dlibs = NULL;
-  while ((direntry = readdir64 (dir)) != NULL)
+  for (int diri = dirn - 1; diri >= 0; diri--)
     {
+      struct dirent64 *direntry = namelist[diri];
       int flag;
       /* We only look at links and regular files.  */
       if (direntry->d_type != DT_UNKNOWN
@@ -1000,7 +1001,9 @@ search_dir (const struct dir_entry *entr
 	}
     }
 
-  closedir (dir);
+  while (dirn--)
+    free (namelist[dirn]);
+  free (namelist);
 
   /* Now dlibs contains a list of all libs - add those to the cache
      and created all symbolic links.  */
openSUSE Build Service is sponsored by