[evolution-patches] possible workaround fix for the glibc gethostbyaddr_r bug?



I've had this patch sitting in my tree for a while now - I had tried to
get one of the users with this problem to test it but he never
responded, so I have no idea if it works or not. However, I'm fairly
confidant that it at least won't break anything (or at least it doesn't
seem to have affected my builds).

it'd be really great if people who can reproduce the problem would try
out this patch and see if it solves the problem...

Jeff

-- 
Jeffrey Stedfast
Evolution Hacker - Ximian, Inc.
fejj ximian com  - www.ximian.com
? gethostbyaddr.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/e-util/ChangeLog,v
retrieving revision 1.409
diff -u -r1.409 ChangeLog
--- ChangeLog	4 Jan 1997 07:49:31 -0000	1.409
+++ ChangeLog	19 Sep 2003 15:03:20 -0000
@@ -1,3 +1,8 @@
+2003-09-19  Jeffrey Stedfast  <fejj ximian com>
+
+	* e-host-utils.c (e_gethostbyaddr_r): Work around a bug in glibc
+	2.3.2's gethostbyaddr_r() implementation.
+
 2003-09-11  Dan Winship  <danw ximian com>
 
 	* Makefile.am (noinst_LTLIBRARIES): Remove libeutil-static.la and
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	19 Sep 2003 15:03:21 -0000
@@ -363,8 +363,20 @@
 	int retval;
 	
 	retval = gethostbyaddr_r (addr, addrlen, type, host, buf, buflen, &hp, herr);
-	if (hp != NULL)
+	if (hp != NULL) {
 		*herr = 0;
+		retval = 0;
+	} else if (retval == 0) {
+		/* glibc 2.3.2 workaround - it seems that
+		 * gethostbyaddr_r will sometimes return 0 on fail and
+		 * fill @host with garbage strings from /etc/hosts
+		 * (failure to parse the file? who knows). Luckily, it
+		 * seems that we can rely on @hp being NULL on
+		 * fail.
+		 */
+		retval = -1;
+	}
+	
 	return retval;
 #endif
 #else /* No support for gethostbyaddr_r */


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