I found it was caused by a struct from the kernel's netlink code being
copied into a char buffer causing it to be unaligned.

I have attached a fix.

-- William
--- old/ipsec-tools-0.6.6/src/racoon/grabmyaddr.c	2007-07-25 17:42:41.000000000 -0700
+++ new/ipsec-tools-0.6.6/src/racoon/grabmyaddr.c	2007-07-25 18:06:08.000000000 -0700
@@ -124,16 +124,23 @@
 
 static void recvaddrs(int fd, struct ifaddrs **ifa, __u32 seq)
 {
-	char	buf[8192];
+#define NL_BUFFER_SIZE NLMSG_SPACE(8192)
+	struct nlmsghdr *nlh = NULL;
 	struct sockaddr_nl nladdr;
-	struct iovec iov = { buf, sizeof(buf) };
+	struct iovec iov;
 	struct ifaddrmsg *m;
 	struct rtattr * rta_tb[IFA_MAX+1];
 	struct ifaddrs *I;
 
+	nlh = (struct nlmsghdr*)malloc(NL_BUFFER_SIZE);
+	memset(nlh, 0, NL_BUFFER_SIZE);
+
+	iov.iov_base = (void*)nlh;
+	iov.iov_len = NL_BUFFER_SIZE;
+
 	while (1) {
 		int status;
-		struct nlmsghdr *h;
+		struct nlmsghdr *h = nlh;
 
 		struct msghdr msg = {
 			(void*)&nladdr, sizeof(nladdr),
@@ -153,7 +160,6 @@
 		if (nladdr.nl_pid) /* Message not from kernel */
 			continue;
 
-		h = (struct nlmsghdr*)buf;
 		while (NLMSG_OK(h, status)) {
 			if (h->nlmsg_seq != seq)
 				goto skip_it;
@@ -210,6 +216,7 @@
 		if (msg.msg_flags & MSG_TRUNC)
 			continue;
 	}
+	free(nlh);
 	return;
 }
 

Reply via email to