File cycle-detection.patch of Package glibc

2012-01-19  Jeff Law  <law@redhat.com>

        * elf/dl-deps.c (_dl_map_object_deps): Fix cycle detection.
        * elf/dl-fini.c (_dl_sort_fini): Likewise


Index: glibc-2.15/elf/dl-deps.c
===================================================================
--- glibc-2.15.orig/elf/dl-deps.c
+++ glibc-2.15/elf/dl-deps.c
@@ -634,7 +634,7 @@ Filters not supported with LD_TRACE_PREL
       /* We can skip looking for the binary itself which is at the front
 	 of the search list.  */
       i = 1;
-      char seen[nlist];
+      unsigned short seen[nlist];
       memset (seen, 0, nlist * sizeof (seen[0]));
       while (1)
 	{
@@ -660,13 +660,13 @@ Filters not supported with LD_TRACE_PREL
 			       (k - i) * sizeof (l_initfini[0]));
 		      l_initfini[k] = thisp;
 
-		      if (seen[i + 1] > 1)
+		      if (seen[i + 1] > nlist - i - 1)
 			{
 			  ++i;
 			  goto next_clear;
 			}
 
-		      char this_seen = seen[i];
+		      unsigned short this_seen = seen[i];
 		      memmove (&seen[i], &seen[i + 1],
 			       (k - i) * sizeof (seen[0]));
 		      seen[k] = this_seen;
Index: glibc-2.15/elf/dl-fini.c
===================================================================
--- glibc-2.15.orig/elf/dl-fini.c
+++ glibc-2.15/elf/dl-fini.c
@@ -39,7 +39,7 @@ _dl_sort_fini (struct link_map **maps, s
   /* We can skip looking for the binary itself which is at the front
      of the search list for the main namespace.  */
   unsigned int i = ns == LM_ID_BASE;
-  char seen[nmaps];
+  unsigned short seen[nmaps];
   memset (seen, 0, nmaps * sizeof (seen[0]));
   while (1)
     {
@@ -79,13 +79,13 @@ _dl_sort_fini (struct link_map **maps, s
 		      used[k] = here_used;
 		    }
 
-		  if (seen[i + 1] > 1)
+		  if (seen[i + 1] > nmaps - i - 1)
 		    {
 		      ++i;
 		      goto next_clear;
 		    }
 
-		  char this_seen = seen[i];
+		  unsigned short this_seen = seen[i];
 		  memmove (&seen[i], &seen[i + 1], (k - i) * sizeof (seen[0]));
 		  seen[k] = this_seen;
 
openSUSE Build Service is sponsored by