From: Harlan Stenn Date: Sun, 9 Feb 2014 08:09:56 +0000 (+0000) Subject: [Bug 1186] ntpd fails with link local IPv6 addresses X-Git-Tag: NTP_4_2_7P420~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3b82055f2f26b07e757e9dc3f8c2839853026e0;p=thirdparty%2Fntp.git [Bug 1186] ntpd fails with link local IPv6 addresses bk: 52f737d4SNIHS7aYTPPO-jBQfj3Hnw --- diff --git a/ChangeLog b/ChangeLog index 862264f55..85e739825 100644 --- 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 -* [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 * [Bug 2551] --disable-local-libevent breaks the build. (4.2.7p417) 2014/02/02 Released by Harlan Stenn -* 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 diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index c14b563c4..28074bc76 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -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; } }