Re: [evolution-patches] fix for bug #41362 - revised



ok, new patch based on notzed's comments.

Jeff

On Thu, 2003-04-17 at 15:13, Jeffrey Stedfast wrote:
> http://bugzilla.ximian.com/show_bug.cgi?id=41362
> 
> I believe the problem is that of memory alignment, but I can't really be
> sure.
> 
> presuming it is memory alignment, I think this patch should fix it.
> 
> Jeff
-- 
Jeffrey Stedfast
Evolution Hacker - Ximian, Inc.
fejj ximian com  - www.ximian.com
? 41362.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/e-util/ChangeLog,v
retrieving revision 1.380
diff -u -r1.380 ChangeLog
--- ChangeLog	16 Apr 2003 17:01:24 -0000	1.380
+++ ChangeLog	18 Apr 2003 18:08:05 -0000
@@ -1,3 +1,9 @@
+2003-04-17  Jeffrey Stedfast  <fejj ximian com>
+
+	* e-host-utils.c (e_gethostbyname_r): Keep our buf ptr aligned to sizeof
+	(char *). Should fix bug #41362.
+	(e_gethostbyaddr_r): Same.
+
 2003-04-14  Jeffrey Stedfast  <fejj ximian com>
 
 	* e-sexp.c: Finished an #if 0'd out port to GObject from an #if
Index: e-host-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-host-utils.c,v
retrieving revision 1.12
diff -u -r1.12 e-host-utils.c
--- e-host-utils.c	9 Apr 2003 18:41:17 -0000	1.12
+++ e-host-utils.c	18 Apr 2003 18:08:05 -0000
@@ -43,6 +43,8 @@
 #endif
 
 
+#define ALIGN(x) (((x) + (sizeof (char *) - 1)) & ~(sizeof (char *) - 1))
+
 #define GETHOST_PROCESS(h, host, buf, buflen, herr) G_STMT_START {     \
 	int num_aliases = 0, num_addrs = 0;                            \
 	int req_length;                                                \
@@ -153,6 +155,7 @@
 		break;
 	}
 }
+
 #endif /* ENABLE_IPv6 */
 
 /**
@@ -190,7 +193,7 @@
 	}
 	
 	len = strlen (res->ai_canonname);
-	if (buflen < IPv6_BUFLEN_MIN + len + 1 + res->ai_addrlen)
+	if (buflen < IPv6_BUFLEN_MIN + len + 1 + res->ai_addrlen + sizeof (char *))
 		return ERANGE;
 	
 	/* h_name */
@@ -217,7 +220,7 @@
 	
 	memcpy (buf, addr, host->h_length);
 	addr = buf;
-	buf += host->h_length;
+	buf += ALIGN (host->h_length);
 	
 	/* h_addr_list */
 	((char **) buf)[0] = addr;
@@ -310,7 +313,7 @@
 	}
 	
 	len = strlen (res->ai_canonname);
-	if (buflen < IPv6_BUFLEN_MIN + len + 1 + res->ai_addrlen)
+	if (buflen < IPv6_BUFLEN_MIN + len + 1 + res->ai_addrlen + sizeof (char *))
 		return ERANGE;
 	
 	/* h_name */
@@ -337,7 +340,7 @@
 	
 	memcpy (buf, addr, host->h_length);
 	addr = buf;
-	buf += host->h_length;
+	buf += ALIGN (host->h_length);
 	
 	/* h_addr_list */
 	((char **) buf)[0] = addr;


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