[evolution-patches] fix for bug #41362



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
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	17 Apr 2003 19:04:29 -0000
@@ -1,3 +1,11 @@
+2003-04-17  Jeffrey Stedfast  <fejj ximian com>
+
+	* e-host-utils.c (e_gethostbyname_r): Align our memory to sizeof
+	(char *). Should fix bug #41362.
+	(e_gethostbyaddr_r): Same.
+	(mem_align): New function to re-align a chunk of memory, updating
+	the 'size' argument to reflect the new size of the memory chunk.
+
 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	17 Apr 2003 19:04:30 -0000
@@ -153,6 +153,18 @@
 		break;
 	}
 }
+
+static char *
+mem_align (char *mem, size_t alignment, size_t *size)
+{
+	char *aligned;
+	
+	aligned = (char *) (((size_t) (mem + (alignment - 1))) & ~(alignment - 1));
+	*size -= (aligned - mem);
+	
+	return aligned;
+}
+
 #endif /* ENABLE_IPv6 */
 
 /**
@@ -178,6 +190,8 @@
 	int retval, len;
 	char *addr;
 	
+	buf = mem_align (buf, sizeof (char *), &buflen);
+	
 	memset (&hints, 0, sizeof (struct addrinfo));
 	hints.ai_flags = AI_CANONNAME;
 	hints.ai_family = PF_UNSPEC;
@@ -297,6 +311,8 @@
 		
 		return -1;
 	}
+	
+	buf = mem_align (buf, sizeof (char *), &buflen);
 	
 	memset (&hints, 0, sizeof (struct addrinfo));
 	hints.ai_flags = AI_CANONNAME;


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