From: Roy Marples Date: Thu, 14 Nov 2013 10:29:14 +0000 (+0000) Subject: Avoid pointer gymnastics. X-Git-Tag: v6.2.0~53 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f1c455dfbc676a5f35249dc3c1aa7c09e12fe8e2;p=thirdparty%2Fdhcpcd.git Avoid pointer gymnastics. Thanks to Christos Zoulas. --- diff --git a/if-bsd.c b/if-bsd.c index d7e466f8..c5c4c330 100644 --- a/if-bsd.c +++ b/if-bsd.c @@ -380,8 +380,9 @@ if_route6(const struct rt6 *rt, int action) #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; \ } \ }