about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-02-16 18:48:51 +0000
committerUlrich Drepper <drepper@redhat.com>2004-02-16 18:48:51 +0000
commitd9a3ae7f4232c7333e2caefa6e265c8ca76d3c6c (patch)
tree6cf629c544ed0c4168250796b09f4864d090eb9a
parentb078c5918eefc410f73a5417600f47eefad0575c (diff)
downloadglibc-d9a3ae7f4232c7333e2caefa6e265c8ca76d3c6c.tar.gz
glibc-d9a3ae7f4232c7333e2caefa6e265c8ca76d3c6c.tar.xz
glibc-d9a3ae7f4232c7333e2caefa6e265c8ca76d3c6c.zip
Update.
2004-02-16  Ulrich Drepper  <drepper@redhat.com>

	* sysdeps/posix/getaddrinfo.c (match_prefix): Correctly match
	partial bytes.
-rw-r--r--ChangeLog5
-rw-r--r--sysdeps/posix/getaddrinfo.c26
2 files changed, 28 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index be57e291c5..a956848653 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-02-16  Ulrich Drepper  <drepper@redhat.com>
+
+	* sysdeps/posix/getaddrinfo.c (match_prefix): Correctly match
+	partial bytes.
+
 2004-02-13  Steven Munroe  <sjmunroe@us.ibm.com>
 
 	* sysdeps/powerpc/powerpc64/__longjmp-common.S: New file.
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 4885a53118..372bc9de4a 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -62,6 +62,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #define UNIX_PATH_MAX  108
 #endif
 
+extern int idna_to_ascii_lz (const char *input, char **output, int flags);
+#define IDNA_SUCCESS 0
+#ifdef HAVE_LIBIDN
+# define SUPPORTED_IDN_FLAGS AI_IDN|AI_CANONIDN
+#else
+# define SUPPORTED_IDN_FLAGS 0
+#endif
+
 struct gaih_service
   {
     const char *name;
@@ -539,6 +547,18 @@ gaih_inet (const char *name, const struct gaih_service *service,
       at->scopeid = 0;
       at->next = NULL;
 
+#if 0
+      if (req->ai_flags & AI_IDN)
+	{
+	  char *p;
+	  rc = idna_to_ascii_lz (name, &p, 0);
+	  if (rc != IDNA_SUCCESS)
+	    return -EAI_IDN_ENCODE;
+	  name = strdupa (p);
+	  free (p);
+	}
+#endif
+
       if (inet_pton (AF_INET, name, at->addr) > 0)
 	{
 	  if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET)
@@ -1049,7 +1069,7 @@ match_prefix (const struct sockaddr_storage *ss, const struct prefixlist *list,
 
       if (bits < 8)
 	{
-	  if ((*mask & (0xff >> bits)) == (*val & (0xff >> bits)))
+	  if ((*mask & (0xff00 >> bits)) == (*val & (0xff00 >> bits)))
 	    /* Match!  */
 	    break;
 	}
@@ -1250,10 +1270,10 @@ getaddrinfo (const char *name, const char *service,
 
   if (hints->ai_flags
       & ~(AI_PASSIVE|AI_CANONNAME|AI_NUMERICHOST|AI_ADDRCONFIG|AI_V4MAPPED
-	  |AI_ALL))
+	  |SUPPORTED_IDN_FLAGS|AI_ALL))
     return EAI_BADFLAGS;
 
-  if ((hints->ai_flags & AI_CANONNAME) && name == NULL)
+  if ((hints->ai_flags & (AI_CANONNAME|AI_CANONIDN)) && name == NULL)
     return EAI_BADFLAGS;
 
   if (hints->ai_flags & AI_ADDRCONFIG)