changeset 2153:56758aee2985 draft

Avoid pointer gymnastics. Thanks to Christos Zoulas.
author Roy Marples <roy@marples.name>
date Thu, 14 Nov 2013 10:29:14 +0000
parents 0721e8a732fd
children c04ac211733e
files if-bsd.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/if-bsd.c	Thu Nov 14 10:20:32 2013 +0000
+++ b/if-bsd.c	Thu Nov 14 10:29:14 2013 +0000
@@ -380,8 +380,9 @@
 #ifdef __KAME__
 #define SCOPE {								      \
 		if (IN6_IS_ADDR_LINKLOCAL(&su.sin.sin6_addr)) {		      \
-			*(uint16_t *)(void *)&su.sin.sin6_addr.s6_addr[2] =   \
-			    htons(su.sin.sin6_scope_id);		      \
+			uint16_t scope = htons(su.sin.sin6_scope_id);	      \
+			memcpy(&su.sin.sin6_addr.s6_addr[2], &scope,	      \
+			    sizeof(scope));				      \
 			su.sin.sin6_scope_id = 0;			      \
 		}							      \
 	}