]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
nameserv: don't return scoped IPv6 addresses
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 29 Jun 2020 14:56:09 +0000 (16:56 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 29 Jun 2020 15:43:35 +0000 (17:43 +0200)
Ignore IPv6 addresses returned by getaddrinfo() that have a non-zero
scope ID to avoid silently ignoring the ID if it was specified with the
% sign in the provided string.

This can be removed when the scope ID is returned from the function and
the callers handle it.

configure
nameserv.c

index 5e62a77ffc8dc0c3a89b0b61427e7f2691ec3fe5..5c4febffc7dbe289ace59c82692cfac2f63f477f 100755 (executable)
--- a/configure
+++ b/configure
@@ -657,6 +657,7 @@ if [ $feat_ipv6 = "1" ] && \
     struct sockaddr_in6 n;
     char p[100];
     n.sin6_addr = in6addr_any;
+    n.sin6_scope_id = 0;
     return !inet_ntop(AF_INET6, &n.sin6_addr.s6_addr, p, sizeof(p));'
 then
   add_def FEAT_IPV6
index c506b73b7527e4d2f04ba9cd447b31d2ecb6a8ab..c87aef083a03ff70f7b12c5baaee25599b987002 100644 (file)
@@ -95,6 +95,9 @@ DNS_Name2IPAddress(const char *name, IPAddr *ip_addrs, int max_addrs)
       case AF_INET6:
         if (address_family != IPADDR_UNSPEC && address_family != IPADDR_INET6)
           continue;
+        /* Don't return an address that would lose a scope ID */
+        if (((struct sockaddr_in6 *)ai->ai_addr)->sin6_scope_id != 0)
+          continue;
         ip_addrs[i].family = IPADDR_INET6;
         memcpy(&ip_addrs[i].addr.in6, &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr.s6_addr,
                sizeof (ip_addrs->addr.in6));