From: Dave Hart Date: Wed, 29 Jul 2009 04:13:53 +0000 (+0000) Subject: [Bug 1272] gsoc_sntp IPv6 build problems under HP-UX 10. X-Git-Tag: NTP_4_2_5P196~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92990b74ae0a40e119cb5287270f863fbf1340f4;p=thirdparty%2Fntp.git [Bug 1272] gsoc_sntp IPv6 build problems under HP-UX 10. [Bug 1273] CID 10: Palisade leaks unit struct in error path. [Bug 1274] CID 67: ensure resolve_hosts() output count and pointers are consistent. [Bug 1275] CID 45: CID 46: old sntp uses uninitialized guesses[0], precs[0]. bk: 4a6fcc81YCfkVsqQErbUm7HWzRPmuw --- diff --git a/ChangeLog b/ChangeLog index 58a73dbea..df763be6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +* [Bug 1272] gsoc_sntp IPv6 build problems under HP-UX 10. +* [Bug 1273] CID 10: Palisade leaks unit struct in error path. +* [Bug 1274] CID 67: ensure resolve_hosts() output count and pointers + are consistent. +* [Bug 1275] CID 45: CID 46: old sntp uses uninitialized guesses[0], + precs[0]. (4.2.5p195) 2009/07/27 Released by Harlan Stenn * cvo.sh: Add support for CentOS, Fedora, Slackware, SuSE. (4.2.5p194) 2009/07/26 Released by Harlan Stenn diff --git a/gsoc_sntp/networking.c b/gsoc_sntp/networking.c index 2049e59e2..35373c110 100644 --- a/gsoc_sntp/networking.c +++ b/gsoc_sntp/networking.c @@ -20,7 +20,7 @@ char adr_buf[INET6_ADDRSTRLEN]; -/* resolve_hosts consumes an arry of hostnames/addresses and its length, stores a pointer +/* resolve_hosts consumes an array of hostnames/addresses and its length, stores a pointer * to the array with the resolved hosts in res and returns the size of the array res. * pref_family enforces IPv4 or IPv6 depending on commandline options and system * capability. If pref_family is NULL or PF_UNSPEC any compatible family will be accepted. @@ -91,8 +91,12 @@ resolve_hosts ( } } - /* Make a list of the addrinfo list entries, start by counting them */ - *res = realloc(tres, sizeof(struct addrinfo *) * resc); + if (resc) + *res = realloc(tres, sizeof(struct addrinfo *) * resc); + else { + free(tres); + *res = NULL; + } return resc; } @@ -239,6 +243,7 @@ recv_bcst_data ( } } } +#ifdef ISC_PLATFORM_HAVEIPV6 else if (IS_IPV6(sas)) { struct ipv6_mreq mdevadr; @@ -279,6 +284,7 @@ recv_bcst_data ( } } } +#endif /* ISC_PLATFORM_HAVEIPV6 */ FD_ZERO(&bcst_fd); FD_SET(rsock, &bcst_fd); @@ -322,8 +328,10 @@ recv_bcst_data ( if (IS_IPV4(sas)) setsockopt(rsock, IPPROTO_IP, IP_DROP_MEMBERSHIP, &btrue, sizeof(btrue)); +#ifdef ISC_PLATFORM_HAVEIPV6 else if (IS_IPV6(sas)) setsockopt(rsock, IPPROTO_IPV6, IPV6_LEAVE_GROUP, &btrue, sizeof(btrue)); +#endif return recv_bytes; } diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index af7c971f8..bc19f3435 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -1261,7 +1261,7 @@ set_wildcard_reuse( DPRINTF(4, ("set SO_REUSEADDR to %s on %s\n", on ? "on" : "off", - stoa(any))); + stoa(&any->sin))); } } #endif /* OS_NEEDS_REUSEADDR_FOR_IFADDRBIND */ diff --git a/ntpd/refclock_palisade.c b/ntpd/refclock_palisade.c index f65be24b1..5969b6e9a 100644 --- a/ntpd/refclock_palisade.c +++ b/ntpd/refclock_palisade.c @@ -264,6 +264,7 @@ palisade_start ( #ifdef DEBUG printf("Palisade(%d) tcgetattr(fd, &tio)\n",unit); #endif + close(fd); return (0); } @@ -275,15 +276,6 @@ palisade_start ( */ up = (struct palisade_unit *) emalloc(sizeof(struct palisade_unit)); - if (!(up)) { - msyslog(LOG_ERR, "Palisade(%d) emalloc: %m",unit); -#ifdef DEBUG - printf("Palisade(%d) emalloc\n",unit); -#endif - (void) close(fd); - return (0); - } - memset((char *)up, 0, sizeof(struct palisade_unit)); up->type = CLK_TYPE(peer); @@ -309,6 +301,8 @@ palisade_start ( #ifdef DEBUG printf("Palisade(%d) tcsetattr(fd, &tio)\n",unit); #endif + close(fd); + free(up); return 0; } diff --git a/sntp/main.c b/sntp/main.c index e40294ec8..0a2b55986 100644 --- a/sntp/main.c +++ b/sntp/main.c @@ -1386,6 +1386,9 @@ triggered if the signal handling works. */ ntp_data data; char text[100]; + guesses[0] = 0; + precs[0] = 0; + if (verbose > 2) { format_time(text,50,0.0,-1.0,0.0,-1.0,-10); fprintf(stderr,"Started=%.6f %s\n",current_time(JAN_1970),text);