about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--sysdeps/posix/getaddrinfo.c51
2 files changed, 44 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index aaa866ecf6..d2b20c4098 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-10  Ulrich Drepper  <drepper@redhat.com>
+
+	* sysdeps/posix/getaddrinfo.c (rfc3484_sort): Store result of
+	native interface lookup in all the relevant places.
+
 2008-01-10  Jakub Jelinek  <jakub@redhat.com>
 	    Ulrich Drepper  <drepper@redhat.com>
 
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 23d463d188..8746725d7a 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -1363,27 +1363,54 @@ rfc3484_sort (const void *p1, const void *p2, void *arg)
 	 (most?) cases.  */
       if (a1->index != a2->index)
 	{
-	  if (a1->native == -1 || a2->native == -1)
+	  int a1_native = a1->native;
+	  int a2_native = a2->native;
+
+	  if (a1_native == -1 || a2_native == -1)
 	    {
-	      /* If we do not have the information use 'native' as the
-		 default.  */
-	      int a1_native = 0;
-	      int a2_native = 0;
-	      __check_native (a1->index, &a1_native, a2->index, &a2_native);
+	      uint32_t a1_index;
+	      if (a1_native == -1)
+		{
+		  /* If we do not have the information use 'native' as
+		     the default.  */
+		  a1_native = 0;
+		  a1_index = a1->index;
+		}
+	      else
+		a1_index = 0xffffffffu;
+
+	      uint32_t a2_index;
+	      if (a2_native == -1)
+		{
+		  /* If we do not have the information use 'native' as
+		     the default.  */
+		  a2_native = 0;
+		  a2_index = a2->index;
+		}
+	      else
+		a2_index = 0xffffffffu;
+
+	      __check_native (a1_index, &a1_native, a2_index, &a2_native);
 
 	      /* Fill in the results in all the records.  */
 	      for (int i = 0; i < src->nresults; ++i)
-		{
-		  if (a1->native == -1 && src->results[i].index == a1->index)
+		if (src->results[i].index == a1_index)
+		  {
+		    assert (src->results[i].native == -1
+			    || src->results[i].native == a1_native);
 		    src->results[i].native = a1_native;
-		  if (a2->native == -1 && src->results[i].index == a2->index)
+		  }
+		else if (src->results[i].index == a2_index)
+		  {
+		    assert (src->results[i].native == -1
+			    || src->results[i].native == a2_native);
 		    src->results[i].native = a2_native;
-		}
+		  }
 	    }
 
-	  if (a1->native && !a2->native)
+	  if (a1_native && !a2_native)
 	    return -1;
-	  if (!a1->native && a2->native)
+	  if (!a1_native && a2_native)
 	    return 1;
 	}
     }