[dovecot-cvs] dovecot/src/lib network.c,1.38.2.1,1.38.2.2

tss at dovecot.org tss at dovecot.org
Mon Oct 16 00:11:43 UTC 2006


Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv2751

Modified Files:
      Tag: branch_1_0
	network.c 
Log Message:
Fix net_ipv6_mapped_ipv4_convert() to be actually portable.



Index: network.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/network.c,v
retrieving revision 1.38.2.1
retrieving revision 1.38.2.2
diff -u -d -r1.38.2.1 -r1.38.2.2
--- network.c	15 Oct 2006 16:19:15 -0000	1.38.2.1
+++ network.c	15 Oct 2006 23:11:10 -0000	1.38.2.2
@@ -574,15 +574,16 @@
 				 struct ip_addr *dest)
 {
 #ifdef HAVE_IPV6
+	static uint8_t v4_prefix[] =
+		{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };
+
 	if (!IPADDR_IS_V6(src))
 		return -1;
-	if (src->ip.in6_u.u6_addr32[0] != 0 ||
-	    src->ip.in6_u.u6_addr32[1] != 0 ||
-	    src->ip.in6_u.u6_addr32[2] != 0xffff0000)
+	if (memcmp(src->ip.s6_addr, v4_prefix, sizeof(v4_prefix)) != 0)
 		return -1;
 
 	dest->family = AF_INET;
-	memcpy(&dest->ip, &src->ip.in6_u.u6_addr32[3], 4);
+	memcpy(&dest->ip, &src->ip.s6_addr[3*4], 4);
 	return 0;
 #else
 	return -1;



More information about the dovecot-cvs mailing list