]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1186] ntpd fails with link local IPv6 addresses
authorHarlan Stenn <stenn@ntp.org>
Sun, 9 Feb 2014 08:09:56 +0000 (08:09 +0000)
committerHarlan Stenn <stenn@ntp.org>
Sun, 9 Feb 2014 08:09:56 +0000 (08:09 +0000)
bk: 52f737d4SNIHS7aYTPPO-jBQfj3Hnw

ChangeLog
ntpd/ntp_io.c

index 862264f55857b97b7f603b10bfa7cb49267d1e6e..85e739825cfbc9f662a8fadf7e60a8fb8fd71184 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,10 @@
+* [Bug 1186] ntpd fails with link local IPv6 addresses.
 (4.2.7p419) 2014/02/08 Released by Harlan Stenn <stenn@ntp.org>
-* [Bug 2466] Wrap NMEA timestamps in 1024 week cycles
+* [Bug 2466] Wrap NMEA timestamps in 1024 week cycles.
 (4.2.7p418) 2014/02/05 Released by Harlan Stenn <stenn@ntp.org>
 * [Bug 2551] --disable-local-libevent breaks the build.
 (4.2.7p417) 2014/02/02 Released by Harlan Stenn <stenn@ntp.org>
-* Bug 2539: doc and code tweaks for NMEA driver
+* [Bug 2539] doc and code tweaks for NMEA driver.
 * Add check for enable stats to ntpd/complete.conf.in
 * Fix typo in html/confopt.html
 (4.2.7p416) 2014/01/31 Released by Harlan Stenn <stenn@ntp.org>
index c14b563c42a5b97ee494b1a4a2469f876308df76..28074bc76003d41d81f2e928a8502f6a6fe5149b 100644 (file)
@@ -709,6 +709,9 @@ is_ip_address(
 {
        struct in_addr in4;
        struct in6_addr in6;
+       struct addrinfo hints;
+       struct addrinfo *result;
+       struct sockaddr_in6 *resaddr6;
        char tmpbuf[128];
        char *pch;
 
@@ -744,14 +747,16 @@ is_ip_address(
                        } else {
                                strlcpy(tmpbuf, host, sizeof(tmpbuf));
                        }
-                       pch = strchr(tmpbuf, '%');
-                       if (pch != NULL)
-                               *pch = '\0';
-
-                       if (inet_pton(AF_INET6, tmpbuf, &in6) == 1) {
+                       ZERO(hints);
+                       hints.ai_family = AF_INET6;
+                       hints.ai_flags |= AI_NUMERICHOST;
+                       if (getaddrinfo(tmpbuf, NULL, &hints, &result) == 0) {
                                AF(addr) = AF_INET6;
-                               SET_ADDR6N(addr, in6);
+                               resaddr6 = (struct sockaddr_in6 *)result->ai_addr;
+                               SET_ADDR6N(addr, resaddr6->sin6_addr);
+                               SET_SCOPE(addr, resaddr6->sin6_scope_id);
 
+                               freeaddrinfo(result);
                                return TRUE;
                        }
                }