From: kn Date: Mon, 15 Nov 2021 18:23:45 +0000 (+0000) Subject: Revert previous X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3a8def13d048d32917b10c957d4234270207668e;p=openbsd Revert previous sockaddr_storage should stay since it is preferred and less error prone. From deraadt OK florian --- 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 * Copyright (c) 2021 Theo de Raadt @@ -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;