about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2006-11-09 20:59:55 +0000
committerJakub Jelinek <jakub@redhat.com>2006-11-09 20:59:55 +0000
commit362d67883f1d8b55049f47b5d56e534f04be0b99 (patch)
tree3e78075972cacd915df7c943ec4cbe8e6c7a2737
parentbff4b406f7f47bb2aca83d90d8d886bfbc8ba447 (diff)
downloadglibc-cvs/fedora-glibc-2_5_90-5.tar.gz
glibc-cvs/fedora-glibc-2_5_90-5.tar.xz
glibc-cvs/fedora-glibc-2_5_90-5.zip
Updated to fedora-glibc-20061109T2048 cvs/fedora-glibc-2_5_90-5
-rw-r--r--ChangeLog12
-rw-r--r--fedora/branch.mk4
-rw-r--r--fedora/glibc.spec.in1
-rw-r--r--string/Makefile2
-rw-r--r--string/strxfrm_l.c11
-rw-r--r--string/tst-strxfrm2.c43
-rw-r--r--sysdeps/posix/getaddrinfo.c8
7 files changed, 71 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 9aef65289d..ba1c875975 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-11-09  Ulrich Drepper  <drepper@redhat.com>
+
+	* sysdeps/posix/getaddrinfo.c (getaddrinfo): Fix test for
+	temporary or deprecated addresses.
+	Patch by Sridhar Samudrala <sri@us.ibm.com>.
+
+	* string/Makefile (tests): Add tst-strxfrm2.
+	* string/tst-strxfrm2.c: New file.
+
 2006-10-09  Jakub Jelinek  <jakub@redhat.com>
 
 	* elf/dl-debug.c (_dl_debug_initialize): Check r->r_map for 0
@@ -5,6 +14,9 @@
 
 2006-11-08  Jakub Jelinek  <jakub@redhat.com>
 
+	* string/strxfrm_l.c (STRXFRM): Do the trailing \1 removal
+	optimization even if needed > n.
+
 	* elf/dl-load.c (decompose_rpath): Return bool rather than void.
 	If l->l_name is on inhibit_rpath list, set sps->dirs to -1 and
 	return false, otherwise return true.
diff --git a/fedora/branch.mk b/fedora/branch.mk
index 01c3d482b7..6226cbbad1 100644
--- a/fedora/branch.mk
+++ b/fedora/branch.mk
@@ -3,5 +3,5 @@ glibc-branch := fedora
 glibc-base := HEAD
 DIST_BRANCH := devel
 COLLECTION := dist-fc4
-fedora-sync-date := 2006-11-09 19:49 UTC
-fedora-sync-tag := fedora-glibc-20061109T1949
+fedora-sync-date := 2006-11-09 20:48 UTC
+fedora-sync-tag := fedora-glibc-20061109T2048
diff --git a/fedora/glibc.spec.in b/fedora/glibc.spec.in
index b457584cc3..da2d43898e 100644
--- a/fedora/glibc.spec.in
+++ b/fedora/glibc.spec.in
@@ -1536,6 +1536,7 @@ rm -f *.filelist*
 - fix --inhibit-rpath (#214569)
 - fix _r_debug content when prelinked ld.so executes
   a program as its argument
+- fix strxfrm
 - powerpc-cpu add-on updates
 
 * Fri Nov  3 2006 Jakub Jelinek <jakub@redhat.com> 2.5.90-4
diff --git a/string/Makefile b/string/Makefile
index a84ebebcaa..3e79f4d909 100644
--- a/string/Makefile
+++ b/string/Makefile
@@ -54,7 +54,7 @@ tests		:= tester inl-tester noinl-tester testcopy test-ffs	\
 		   bug-strncat1 bug-strspn1 bug-strpbrk1 tst-bswap	\
 		   tst-strtok tst-strxfrm bug-strcoll1 tst-strfry	\
 		   bug-strtok1 $(addprefix test-,$(strop-tests))	\
-		   bug-envz1
+		   bug-envz1 tst-strxfrm2
 distribute	:= memcopy.h pagecopy.h tst-svc.expect test-string.h
 
 
diff --git a/string/strxfrm_l.c b/string/strxfrm_l.c
index 5335601919..f158833f05 100644
--- a/string/strxfrm_l.c
+++ b/string/strxfrm_l.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1995,96,97,2002, 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 2002, 2004, 2005, 2006
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Ulrich Drepper <drepper@gnu.org>, 1995.
 
@@ -96,6 +97,7 @@ STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n, __locale_t l)
   const int32_t *indirect;
   uint_fast32_t pass;
   size_t needed;
+  size_t last_needed;
   const USTRING_TYPE *usrc;
   size_t srclen = STRLEN (src);
   int32_t *idxarr;
@@ -197,6 +199,7 @@ STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n, __locale_t l)
 	 this is true for all of them.  */
       int position = rule & sort_position;
 
+      last_needed = needed;
       if (position == 0)
 	{
 	  for (idxcnt = 0; idxcnt < idxmax; ++idxcnt)
@@ -426,11 +429,11 @@ STRXFRM (STRING_TYPE *dest, const STRING_TYPE *src, size_t n, __locale_t l)
      a `position' rule at the end and if no non-ignored character
      is found the last \1 byte is immediately followed by a \0 byte
      signalling this.  We can avoid the \1 byte(s).  */
-  if (needed <= n && needed > 2 && dest[needed - 2] == L('\1'))
+  if (needed > 2 && needed == last_needed + 1)
     {
       /* Remove the \1 byte.  */
-      --needed;
-      dest[needed - 1] = L('\0');
+      if (--needed < n)
+	dest[needed - 1] = L('\0');
     }
 
   /* Free the memory if needed.  */
diff --git a/string/tst-strxfrm2.c b/string/tst-strxfrm2.c
new file mode 100644
index 0000000000..31fc42cc93
--- /dev/null
+++ b/string/tst-strxfrm2.c
@@ -0,0 +1,43 @@
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+
+static int
+do_test (void)
+{
+  int res = 0;
+
+  char buf[10];
+  size_t l1 = strxfrm (NULL, "ab", 0);
+  size_t l2 = strxfrm (buf, "ab", 1);
+  size_t l3 = strxfrm (buf, "ab", sizeof (buf));
+
+  if (l1 != l2 || l1 != l3)
+    {
+      puts ("C locale test failed");
+      res = 1;
+    }
+
+  if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
+    {
+      puts ("setlocale failed");
+      res = 1;
+    }
+  else
+    {
+      l1 = strxfrm (NULL, "ab", 0);
+      l2 = strxfrm (buf, "ab", 1);
+      l3 = strxfrm (buf, "ab", sizeof (buf));
+
+      if (l1 != l2 || l1 != l3)
+	{
+	  puts ("UTF-8 locale test failed");
+	  res = 1;
+	}
+    }
+
+  return res;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 84a6293365..b4966852a7 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -2085,10 +2085,12 @@ getaddrinfo (const char *name, const char *service,
 
 		  if (q->ai_family == PF_INET6 && in6ai != NULL)
 		    {
-		      /* See whether the address is the list of deprecated
-			 or temporary addresses.  */
+		      /* See whether the source address is the list of
+			 deprecated or temporary addresses.  */
 		      struct in6addrinfo tmp;
-		      memcpy (tmp.addr, q->ai_addr, IN6ADDRSZ);
+		      struct sockaddr_in6 *sin6p
+			= (struct sockaddr_in6 *) &results[i].source_addr;
+		      memcpy (tmp.addr, &sin6p->sin6_addr, IN6ADDRSZ);
 
 		      struct in6addrinfo *found
 			= bsearch (&tmp, in6ai, in6ailen, sizeof (*in6ai),