From e1aba9d040d07a3cc30667a17b9e8d91567f2389 Mon Sep 17 00:00:00 2001 From: Ron Date: Sat, 27 Jun 2009 04:44:28 +0930 Subject: Avoid type-punned pointers that break strict-aliasing Signed-off-by: Ron Lee Signed-off-by: Mike Frysinger --- libc/inet/getaddrinfo.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'libc/inet') diff --git a/libc/inet/getaddrinfo.c b/libc/inet/getaddrinfo.c index 1953e6f7a..2839bdaf4 100644 --- a/libc/inet/getaddrinfo.c +++ b/libc/inet/getaddrinfo.c @@ -544,7 +544,8 @@ gaih_inet(const char *name, const struct gaih_service *service, if (scope_delim != NULL) { int try_numericscope = 0; - if (IN6_IS_ADDR_LINKLOCAL(at->addr) || IN6_IS_ADDR_MC_LINKLOCAL(at->addr)) { + uint32_t *a32 = (uint32_t*)at->addr; + if (IN6_IS_ADDR_LINKLOCAL(a32) || IN6_IS_ADDR_MC_LINKLOCAL(at->addr)) { at->scopeid = if_nametoindex(scope_delim + 1); if (at->scopeid == 0) try_numericscope = 1; @@ -622,8 +623,10 @@ gaih_inet(const char *name, const struct gaih_service *service, #endif if (req->ai_family == 0 || req->ai_family == AF_INET) { atr->family = AF_INET; - if ((req->ai_flags & AI_PASSIVE) == 0) - *(uint32_t*)atr->addr = htonl(INADDR_LOOPBACK); + if ((req->ai_flags & AI_PASSIVE) == 0) { + uint32_t *a = (uint32_t*)atr->addr; + *a = htonl(INADDR_LOOPBACK); + } } } -- cgit v1.2.3