summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlemens Nanni <kn@cvs.openbsd.org>2021-11-15 18:23:46 +0000
committerKlemens Nanni <kn@cvs.openbsd.org>2021-11-15 18:23:46 +0000
commit874e45f9ea45c29e86b87067449ddb403edb7ba6 (patch)
tree5059a1afc01c68ab0aeec13bfa4740cbdedb984e
parent797d6b5e9503f5341e4fa6806247fce023445d17 (diff)
Revert previous
sockaddr_storage should stay since it is preferred and less error prone. From deraadt OK florian
-rw-r--r--sbin/resolvd/resolvd.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/sbin/resolvd/resolvd.c b/sbin/resolvd/resolvd.c
index e51e7d5661b..23d12e7eb3e 100644
--- a/sbin/resolvd/resolvd.c
+++ b/sbin/resolvd/resolvd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolvd.c,v 1.22 2021/11/15 17:33:51 kn Exp $ */
+/* $OpenBSD: resolvd.c,v 1.23 2021/11/15 18:23:45 kn Exp $ */
/*
* Copyright (c) 2021 Florian Obser <florian@openbsd.org>
* Copyright (c) 2021 Theo de Raadt <deraadt@openbsd.org>
@@ -467,32 +467,27 @@ handle_route_message(struct rt_msghdr *rtm, struct sockaddr **rti_info)
/* Add the new proposals */
for (i = 0; i < rdns_count; i++) {
- struct sockaddr_in sin;
- struct sockaddr_in6 sin6;
- struct sockaddr *sa;
- int new, err;
+ struct sockaddr_storage ss;
+ struct sockaddr_in *sin = (struct sockaddr_in *)&ss;
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&ss;
+ int new, err;
+ memset(&ss, 0, sizeof(ss));
+ ss.ss_family = af;
new = findslot(learning);
switch (af) {
case AF_INET:
- memset(&sin, 0, sizeof(sin));
- memcpy(&sin.sin_addr, src, addrsz);
- sa = (struct sockaddr *) &sin;
- sa->sa_len = sizeof(sin);
+ memcpy(&sin->sin_addr, src, addrsz);
break;
case AF_INET6:
- memset(&sin6, 0, sizeof(sin6));
- memcpy(&sin6.sin6_addr, src, addrsz);
- if (IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr))
- sin6.sin6_scope_id = rtm->rtm_index;
- sa = (struct sockaddr *) &sin6;
- sa->sa_len = sizeof(sin6);
+ memcpy(&sin6->sin6_addr, src, addrsz);
+ if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr))
+ sin6->sin6_scope_id = rtm->rtm_index;
break;
}
- sa->sa_family = af;
src += addrsz;
- if ((err = getnameinfo(sa, sa->sa_len,
+ if ((err = getnameinfo((struct sockaddr *)&ss, ss.ss_len,
learning[new].ip, sizeof(learning[new].ip),
NULL, 0, NI_NUMERICHOST)) == 0) {
learning[new].prio = rtm->rtm_priority;