Subject: IPv6, rarpd, and hostent alignment on sparc
To: None <tech-net@netbsd.org>
From: David Brownlee <abs@anim.dreamworks.com>
List: tech-net
Date: 07/04/1999 13:21:07
	In the process of upgrading my sparc to -current and I noticed
	that rarpd was dumping core.

	It seemed to be assuming it could treat hp->h_addr_list as
	suitably aligned for 32bit values.

	The following patch works for me, but I don't know if its the
	right approach, and if other programs out there might be breaking
	in a similar way. (rpc.bootparamd also seems to be broken, but in
	a less obvious fashion).

	Note: I'm still running a.out, and its possible another rebuild
	may help matters (I'm trying that now :), but any thoughts
	appreciated!

			Thanks

Index: rarpd.c
===================================================================
RCS file: /cvsroot/basesrc/usr.sbin/rarpd/rarpd.c,v
retrieving revision 1.33
diff -u -u -r1.33 rarpd.c
--- rarpd.c	1999/06/06 02:58:23	1.33
+++ rarpd.c	1999/07/04 20:20:01
@@ -92,7 +92,7 @@
  */
 struct if_info *iflist;
 
-u_int32_t choose_ipaddr __P((u_int32_t **, u_int32_t, u_int32_t));
+u_int32_t choose_ipaddr __P((char **, u_int32_t, u_int32_t));
 void	debug __P((const char *,...));
 void	init_all __P((void));
 void	init_one __P((char *, u_int32_t));
@@ -581,14 +581,16 @@
  */
 u_int32_t
 choose_ipaddr(alist, net, netmask)
-	u_int32_t **alist;
+	char **alist;
 	u_int32_t net;
 	u_int32_t netmask;
 {
+        u_int32_t addr;
 
 	for (; *alist; ++alist) {
-		if ((**alist & netmask) == net)
-			return **alist;
+		memcpy(&addr,*alist,sizeof(u_int32_t));
+		if ((addr & netmask) == net)
+			return addr;
 	}
 	return 0;
 }
@@ -628,7 +630,7 @@
 		/* NOTREACHED */
 	}
 	for (;; ii = ii->ii_alias) {
-		target_ipaddr = choose_ipaddr((u_int32_t **) hp->h_addr_list,
+		target_ipaddr = choose_ipaddr(hp->h_addr_list,
 		    ii->ii_ipaddr & ii->ii_netmask, ii->ii_netmask);
 		if (target_ipaddr != 0)
 			break;
		David/absolute

    "Consistency is the last refuge of the unimaginative." - Oscar Wilde