diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2020-05-10 06:44:08 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2020-05-10 06:44:08 +0000 |
commit | 9b109e77c7175b11d8657b443165bef46b32c81b (patch) | |
tree | 4e0ab72234d6a5067e48344725ccc8dbde75f094 /sbin/unwind/resolver.c | |
parent | 1b96e80d785258e5934e36952cbe9a1256483855 (diff) |
sockaddr_rtdns does not guarantee alignment of the buffer. So first
memcpy the address into a local var before comparing it with code
that reads ints using int *. at least sparc64 and landisk suffer from this.
with and ok jca@
Diffstat (limited to 'sbin/unwind/resolver.c')
-rw-r--r-- | sbin/unwind/resolver.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sbin/unwind/resolver.c b/sbin/unwind/resolver.c index 3974ad39db3..874ad5e76b3 100644 --- a/sbin/unwind/resolver.c +++ b/sbin/unwind/resolver.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resolver.c,v 1.123 2020/03/19 19:27:21 tobhe Exp $ */ +/* $OpenBSD: resolver.c,v 1.124 2020/05/10 06:44:07 otto Exp $ */ /* * Copyright (c) 2018 Florian Obser <florian@openbsd.org> @@ -1918,18 +1918,23 @@ replace_autoconf_forwarders(struct imsg_rdns_proposal *rdns_proposal) } for (i = 0; i < rdns_count; i++) { + struct in_addr addr4; + struct in6_addr addr6; + switch (af) { case AF_INET: - if (((struct in_addr *)src)->s_addr == INADDR_LOOPBACK) + memcpy(&addr4, src, sizeof(struct in_addr)); + if (addr4.s_addr == INADDR_LOOPBACK) continue; - ns = inet_ntop(af, (struct in_addr *)src, ntopbuf, + ns = inet_ntop(af, &addr4, ntopbuf, INET6_ADDRSTRLEN); src += sizeof(struct in_addr); break; case AF_INET6: - if (IN6_IS_ADDR_LOOPBACK((struct in6_addr *)src)) + memcpy(&addr6, src, sizeof(struct in6_addr)); + if (IN6_IS_ADDR_LOOPBACK(&addr6)) continue; - ns = inet_ntop(af, (struct in6_addr *)src, ntopbuf, + ns = inet_ntop(af, &addr6, ntopbuf, INET6_ADDRSTRLEN); src += sizeof(struct in6_addr); } |