]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1471] CID 120 CID 121 CID 122 is_ip_address() uninit family.
authorDave Hart <hart@ntp.org>
Mon, 1 Feb 2010 04:40:15 +0000 (04:40 +0000)
committerDave Hart <hart@ntp.org>
Mon, 1 Feb 2010 04:40:15 +0000 (04:40 +0000)
[Bug 1472] CID 116 CID 117 minor warnings in new DNS code.

bk: 4b665b2fBsbs_TvJiquvPh7sFf514w

ChangeLog
include/ntp_io.h
ntpd/ntp_config.c
ntpd/ntp_intres.c
ntpd/ntp_io.c
ntpd/ntpd.c

index 2ce8fc73a2d247574e4837f188b81bf7368ce9c5..25e2c0fd00daff3b5dfe28165c7d9d5544f61fbe 100644 (file)
--- 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 <stenn@ntp.org>
 * Include (4.2.6p1) - [Bug 1467] Fix bogus rebuild of sntp/sntp.html.
 (4.2.7p12) 2010/01/30 Released by Harlan Stenn <stenn@ntp.org>
index 685524895355e32e03ce7c86500a25ca89e5dca5..ecee9ab27641c4982a43053cbbc91f19dd0bd74e 100644 (file)
@@ -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,
index 859ae597cf849f7dfc8716f54833d4bf0fd3c460..ef9dbf7415908dad4a88c4934376151a689194a4 100644 (file)
@@ -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]) {
index df30a3e0667e61051545bad26230aa5b7b4c608a..96c6b56354ee05db408ac9d07ad62012464d92d6 100644 (file)
@@ -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;
index ba64bcc36c25a3233150832620d57dfe25f28e09..50febc1a5efb651c7e5c7ea5c2f89cfa4302f24b 100644 (file)
@@ -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);
index 423e8c5a683a5842e211437ad9a94b659d15a325..ed5dd017e39ff0ea4702f7009d01870657a203fe 100644 (file)
@@ -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++;
                }