Module Name:    src
Committed By:   riz
Date:           Sun Nov 21 21:30:21 UTC 2010

Modified Files:
        src/sbin/routed [netbsd-5]: if.c

Log Message:
Pull up following revision(s) (requested by martin in ticket #1460):
        sbin/routed/if.c: revision 1.29
Memcpy into local variable to ensure proper alignement.
Fixes PR port-sparc64/43965.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.26.16.1 src/sbin/routed/if.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/routed/if.c
diff -u src/sbin/routed/if.c:1.26 src/sbin/routed/if.c:1.26.16.1
--- src/sbin/routed/if.c:1.26	Tue Aug 14 03:39:19 2007
+++ src/sbin/routed/if.c	Sun Nov 21 21:30:20 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.26 2007/08/14 03:39:19 dyoung Exp $	*/
+/*	$NetBSD: if.c,v 1.26.16.1 2010/11/21 21:30:20 riz Exp $	*/
 
 /*
  * Copyright (c) 1983, 1993
@@ -37,7 +37,7 @@
 #include "pathnames.h"
 
 #ifdef __NetBSD__
-__RCSID("$NetBSD: if.c,v 1.26 2007/08/14 03:39:19 dyoung Exp $");
+__RCSID("$NetBSD: if.c,v 1.26.16.1 2010/11/21 21:30:20 riz Exp $");
 #elif defined(__FreeBSD__)
 __RCSID("$FreeBSD$");
 #else
@@ -693,7 +693,7 @@
 	struct rt_entry *rt;
 	size_t needed;
 	int mib[6];
-	struct if_msghdr *ifm;
+	struct if_msghdr ifm;
 	struct ifa_msghdr *ifam, *ifam_lim, *ifam2;
 	int in, ierr, out, oerr;
 	struct intnet *intnetp;
@@ -751,25 +751,26 @@
 		if (ifam->ifam_type == RTM_IFINFO) {
 			const struct sockaddr_dl *sdl;
 
-			ifm = (struct if_msghdr *)ifam;
+			memcpy(&ifm, ifam, sizeof ifm);
 			/* make prototype structure for the IP aliases
 			 */
 			memset(&ifs0, 0, sizeof(ifs0));
 			ifs0.int_rip_sock = -1;
-			ifs0.int_index = ifm->ifm_index;
-			ifs0.int_if_flags = ifm->ifm_flags;
+			ifs0.int_index = ifm.ifm_index;
+			ifs0.int_if_flags = ifm.ifm_flags;
 			ifs0.int_state = IS_CHECKED;
 			ifs0.int_query_time = NEVER;
 			ifs0.int_act_time = now.tv_sec;
 			ifs0.int_data.ts = now.tv_sec;
-			ifs0.int_data.ipackets = ifm->ifm_data.ifi_ipackets;
-			ifs0.int_data.ierrors = ifm->ifm_data.ifi_ierrors;
-			ifs0.int_data.opackets = ifm->ifm_data.ifi_opackets;
-			ifs0.int_data.oerrors = ifm->ifm_data.ifi_oerrors;
+			ifs0.int_data.ipackets = ifm.ifm_data.ifi_ipackets;
+			ifs0.int_data.ierrors = ifm.ifm_data.ifi_ierrors;
+			ifs0.int_data.opackets = ifm.ifm_data.ifi_opackets;
+			ifs0.int_data.oerrors = ifm.ifm_data.ifi_oerrors;
 #ifdef sgi
-			ifs0.int_data.odrops = ifm->ifm_data.ifi_odrops;
+			ifs0.int_data.odrops = ifm.ifm_data.ifi_odrops;
 #endif
-			sdl = (const struct sockaddr_dl *)(ifm + 1);
+			sdl = (const struct sockaddr_dl *)
+				((struct if_msghdr *)ifam + 1);
 			/* NUL-termination by memset, above. */
 			memcpy(ifs0.int_name, sdl->sdl_data,
 				MIN(sizeof(ifs0.int_name) - 1, sdl->sdl_nlen));

Reply via email to