[evolution-patches] fix for the second half of bug #46006, getaddrinfo suckage



so yea, getaddrinfo's API sucks hardcore.

http://www.opengroup.org/onlinepubs/007904975/functions/getaddrinfo.html

If nodename is not null, and if requested by the AI_CANONNAME flag, the ai_canonname field of the first returned addrinfo structure shall point to a null-terminated string containing the canonical name corresponding to the input nodename; if the canonical name is not available, then ai_canonname shall refer to the nodename argument or a string with the same contents. The contents of the ai_flags field of the returned structures are undefined.

attached patch fixes.

-- 
Jeffrey Stedfast
Evolution Hacker - Ximian, Inc.
fejj ximian com  - www.ximian.com
? 46006-2.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/e-util/ChangeLog,v
retrieving revision 1.398.2.6
diff -u -r1.398.2.6 ChangeLog
--- ChangeLog	4 Jan 1997 06:07:00 -0000	1.398.2.6
+++ ChangeLog	25 Sep 2003 16:05:17 -0000
@@ -1,3 +1,10 @@
+2003-09-25  Jeffrey Stedfast  <fejj ximian com>
+
+	* e-host-utils.c (e_gethostbyaddr_r): Make sure that
+	res->ai_canonname is non-NULL and that it doesn't match the
+	numeric host address that we were trying to resolve. Fixes the
+	second half of bug #46006.
+
 2003-09-04  Dan Winship  <danw ximian com>
 
 	* Makefile.am: Kill off libeconduit-static: it was only needed for
Index: e-host-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-host-utils.c,v
retrieving revision 1.14
diff -u -r1.14 e-host-utils.c
--- e-host-utils.c	29 Apr 2003 02:14:37 -0000	1.14
+++ e-host-utils.c	25 Sep 2003 16:05:18 -0000
@@ -313,6 +313,19 @@
 		return -1;
 	}
 	
+	/* If nodename is not null, and if requested by the AI_CANONNAME flag, the ai_canonname
+	 * field of the first returned addrinfo structure shall point to a null-terminated
+	 * string containing the canonical name corresponding to the input nodename; if the
+	 * canonical name is not available, then ai_canonname shall refer to the nodename
+	 * argument or a string with the same contents.
+	 *
+	 * Note: NetBSD seems to set res->ai_canonname to NULL in this case instead.
+	 */
+	if (!res->ai_canonname || !strcmp (res->ai_canonname, name)) {
+		*herr = HOST_NOT_FOUND;
+		return -1;
+	}
+	
 	len = ALIGN (strlen (res->ai_canonname) + 1);
 	if (buflen < IPv6_BUFLEN_MIN + len + res->ai_addrlen + sizeof (char *))
 		return ERANGE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]