From: Dave Hart Date: Mon, 1 Feb 2010 04:40:15 +0000 (+0000) Subject: [Bug 1471] CID 120 CID 121 CID 122 is_ip_address() uninit family. X-Git-Tag: NTP_4_2_7P14~1^2~1^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9f6c47d01f59bcc9a26ad590eafd228df938161;p=thirdparty%2Fntp.git [Bug 1471] CID 120 CID 121 CID 122 is_ip_address() uninit family. [Bug 1472] CID 116 CID 117 minor warnings in new DNS code. bk: 4b665b2fBsbs_TvJiquvPh7sFf514w --- diff --git a/ChangeLog b/ChangeLog index 2ce8fc73a..25e2c0fd0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ +* [Bug 1471] CID 120 CID 121 CID 122 is_ip_address() uninit family. +* [Bug 1472] CID 116 CID 117 minor warnings in new DNS code. (4.2.7p13) 2010/01/31 Released by Harlan Stenn * Include (4.2.6p1) - [Bug 1467] Fix bogus rebuild of sntp/sntp.html. (4.2.7p12) 2010/01/30 Released by Harlan Stenn diff --git a/include/ntp_io.h b/include/ntp_io.h index 685524895..ecee9ab27 100644 --- a/include/ntp_io.h +++ b/include/ntp_io.h @@ -80,7 +80,7 @@ typedef enum { SOCKET move_fd(SOCKET fd); isc_boolean_t get_broadcastclient_flag(void); -isc_boolean_t is_ip_address(const char *, isc_netaddr_t *); +isc_boolean_t is_ip_address(const char *, u_short, isc_netaddr_t *); extern void sau_from_netaddr(sockaddr_u *, const isc_netaddr_t *); extern void add_nic_rule(nic_rule_match match_type, const char *if_name, int prefixlen, diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index 859ae597c..ef9dbf741 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -2387,7 +2387,8 @@ config_nic_rules( pchSlash = strchr(if_name, '/'); if (pchSlash != NULL) *pchSlash = '\0'; - if (is_ip_address(if_name, &netaddr)) { + if (is_ip_address(if_name, AF_UNSPEC, + &netaddr)) { match_type = MATCH_IFADDR; if (pchSlash != NULL) { sscanf(pchSlash + 1, "%d", @@ -3321,11 +3322,9 @@ config_peers( * getaddrinfo in the mainline with it. Otherwise * hand it off to the blocking child. */ - memset(&i_netaddr, 0, sizeof(i_netaddr)); - i_netaddr.family = (u_short)curr_peer->addr->type; - if (1 == num_needed && is_ip_address(curr_peer->addr->address, + (u_short)curr_peer->addr->type, &i_netaddr)) { AF(&peeraddr) = (u_short)i_netaddr.family; @@ -3505,10 +3504,9 @@ config_unpeers( * getaddrinfo in the mainline with it. Otherwise * hand it off to the blocking child. */ - memset(&i_netaddr, 0, sizeof(i_netaddr)); - i_netaddr.family = (u_short)curr_unpeer->addr->type; - - if (is_ip_address(curr_unpeer->addr->address, &i_netaddr)) { + if (is_ip_address(curr_unpeer->addr->address, + (u_short)curr_unpeer->addr->type, + &i_netaddr)) { AF(&peeraddr) = (u_short)i_netaddr.family; if (AF_INET6 == i_netaddr.family) @@ -4346,7 +4344,7 @@ get_multiple_netnums( } lookup = nameornum; - if (is_ip_address(nameornum, &ipaddr)) { + if (is_ip_address(nameornum, AF_UNSPEC, &ipaddr)) { hints.ai_flags = AI_NUMERICHOST; hints.ai_family = ipaddr.family; if ('[' == nameornum[0]) { diff --git a/ntpd/ntp_intres.c b/ntpd/ntp_intres.c index df30a3e06..96c6b5635 100644 --- a/ntpd/ntp_intres.c +++ b/ntpd/ntp_intres.c @@ -217,7 +217,10 @@ getaddrinfo_sometime( next_dns_timeslot = max(now, next_dns_timeslot); gai_req->scheduled = now; gai_req->earliest = next_dns_timeslot; - gai_req->hints = *hints; + if (NULL == hints) + memset(&gai_req->hints, 0, sizeof(gai_req->hints)); + else + gai_req->hints = *hints; gai_req->retry = INITIAL_DNS_RETRY; gai_req->callback = callback; gai_req->context = context; diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index ba64bcc36..50febc1a5 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -761,6 +761,7 @@ remove_asyncio_reader( isc_boolean_t is_ip_address( const char * host, + u_short af, isc_netaddr_t * addr ) { @@ -781,13 +782,13 @@ is_ip_address( * addresses (up to 46 bytes), the delimiter character and the * terminating NULL character. */ - if (AF_UNSPEC == addr->family || AF_INET == addr->family) + if (AF_UNSPEC == af || AF_INET == af) if (inet_pton(AF_INET, host, &in4) == 1) { isc_netaddr_fromin(addr, &in4); return (ISC_TRUE); } - if (AF_UNSPEC == addr->family || AF_INET6 == addr->family) + if (AF_UNSPEC == af || AF_INET6 == af) if (sizeof(tmpbuf) > strlen(host)) { if ('[' == host[0]) { strncpy(tmpbuf, &host[1], sizeof(tmpbuf)); @@ -1125,7 +1126,8 @@ add_nic_rule( } else if (MATCH_IFADDR == match_type) { NTP_REQUIRE(NULL != if_name); /* set rule->netaddr */ - is_ip = is_ip_address(if_name, &rule->netaddr); + is_ip = is_ip_address(if_name, AF_UNSPEC, + &rule->netaddr); NTP_REQUIRE(is_ip); } else NTP_REQUIRE(NULL == if_name); diff --git a/ntpd/ntpd.c b/ntpd/ntpd.c index 423e8c5a6..ed5dd017e 100644 --- a/ntpd/ntpd.c +++ b/ntpd/ntpd.c @@ -367,8 +367,10 @@ change_logfile( new_file = fopen(abs_fname, "a"); } - if (NULL == new_file) + if (NULL == new_file) { + free(abs_fname); return -1; + } /* leave a pointer in the old log */ if (log_fname != syslog_abs_fname) @@ -687,9 +689,10 @@ ntpdmain( while (ifacect-- > 0) { add_nic_rule( - is_ip_address(*ifaces, &netaddr) - ? MATCH_IFADDR - : MATCH_IFNAME, + is_ip_address(*ifaces, AF_UNSPEC, + &netaddr) + ? MATCH_IFADDR + : MATCH_IFNAME, *ifaces, -1, ACTION_LISTEN); ifaces++; }