From: Dave Hart Date: Thu, 24 Dec 2009 22:04:26 +0000 (+0000) Subject: [Bug 1425] unpeer by association ID sets up for duplicate free(). X-Git-Tag: NTP_4_2_6P1_RC2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=431a75e723667ff343cf69336844a969930a0321;p=thirdparty%2Fntp.git [Bug 1425] unpeer by association ID sets up for duplicate free(). [Bug 1434] HP-UX 11 ip_mreq undeclared, _HPUX_SOURCE helps some. Use HAVE_WORKING_FORK instead of HAVE_FORK to avoid broken fork(). bk: 4b33e56aef6-ziGRDaAHnwswgbQpMg --- diff --git a/ChangeLog b/ChangeLog index 1582ff765..7b7b83c09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,11 +4,13 @@ * [Bug 1416] MAXDNAME undefined on Solaris 2.6. * [Bug 1419] ntpdate, ntpdc, sntp, ntpd ignore configure --bindir. * [Bug 1424] Fix check for rtattr (rtnetlink.h). +* [Bug 1425] unpeer by association ID sets up for duplicate free(). * [Bug 1426] scripts/VersionName needs . on the search path. * [Bug 1427] quote missing in ./build - shows up on NetBSD. * [Bug 1428] Use AC_HEADER_RESOLV to fix breaks from resolv.h * [Bug 1429] ntpd -4 option does not reliably force IPv4 resolution. * [Bug 1431] System headers must come before ntp headers in ntp_intres.c . +* [Bug 1434] HP-UX 11 ip_mreq undeclared, _HPUX_SOURCE helps some. --- (4.2.6p1-RC1) 2009/12/20 Released by Harlan Stenn diff --git a/configure.ac b/configure.ac index 85962d692..db824340f 100644 --- a/configure.ac +++ b/configure.ac @@ -2138,36 +2138,57 @@ case "$ac_cv_var_ppsclock" in yes) AC_DEFINE(PPS, 1, [Do we have the ppsclock streams module?]) ;; esac -AC_CACHE_CHECK([for kernel multicast support], ac_cv_var_mcast, - [ac_cv_var_mcast=no - case "$host" in - i386-sequent-sysv4) ;; - *) AC_EGREP_CPP(yes, - [#include -#ifdef IP_ADD_MEMBERSHIP - yes -#endif - ], ac_cv_var_mcast=yes) ;; - esac]) -case "$ac_cv_var_mcast" in - yes) - AC_DEFINE(MCAST, 1, [Does the kernel support multicasting IP?]) - AC_CACHE_CHECK([[arg type needed for IP*_MULTICAST_LOOP for setsockopt()]], - ac_cv_var_typeof_ip_multicast_loop, - [case "$host" in - *-*-netbsd*|*-*-*linux*) - ac_cv_var_typeof_ip_multicast_loop=u_int - ;; - *-*-winnt*) - ac_cv_var_typeof_ip_multicast_loop=BOOL - ;; - *) ac_cv_var_typeof_ip_multicast_loop=u_char +AC_CACHE_CHECK( + [for multicast IP support], + ntp_cv_multicast, + [ + ntp_cv_multicast=no + case "$host" in + i386-sequent-sysv4) ;; - esac]) - AC_DEFINE_UNQUOTED(TYPEOF_IP_MULTICAST_LOOP, - $ac_cv_var_typeof_ip_multicast_loop, - [What type to use for setsockopt]) - ;; + *) + AC_COMPILE_IFELSE( + AC_LANG_PROGRAM( + [ + #ifdef HAVE_NETINET_IN_H + #include + #endif + ], + [ + struct ip_mreq ipmr; + ipmr.imr_interface.s_addr = 0; + ] + ), + [ntp_cv_multicast=yes], + [] + ) + esac + ] +) + +case "$ntp_cv_multicast" in + yes) + AC_DEFINE(MCAST, 1, [Does the target support multicast IP?]) + AC_CACHE_CHECK( + [[arg type needed for setsockopt() IP*_MULTICAST_LOOP]], + ntp_cv_typeof_ip_multicast_loop, + [ + case "$host" in + *-*-netbsd*|*-*-*linux*) + ntp_cv_typeof_ip_multicast_loop=u_int + ;; + *-*-winnt*) + ntp_cv_typeof_ip_multicast_loop=BOOL + ;; + *) + ntp_cv_typeof_ip_multicast_loop=u_char + esac + ] + ) + AC_DEFINE_UNQUOTED([TYPEOF_IP_MULTICAST_LOOP], + $ntp_cv_typeof_ip_multicast_loop, + [What type to use for setsockopt] + ) esac AC_CACHE_CHECK([[availability of ntp_{adj,get}time()]], ac_cv_var_ntp_syscalls, diff --git a/include/ntp_intres.h b/include/ntp_intres.h index 1072833aa..53c8a63a4 100644 --- a/include/ntp_intres.h +++ b/include/ntp_intres.h @@ -7,7 +7,7 @@ * to using numeric IP addresses. */ #if defined(VMS) || defined (SYS_VXWORKS) || \ - (!defined(HAVE_FORK) && !defined(SYS_WINNT)) + (!defined(HAVE_WORKING_FORK) && !defined(SYS_WINNT)) #define NO_INTRES #endif diff --git a/m4/os_cflags.m4 b/m4/os_cflags.m4 index 40bf18e44..7fac93bd1 100644 --- a/m4/os_cflags.m4 +++ b/m4/os_cflags.m4 @@ -40,6 +40,7 @@ AC_DEFUN([NTP_OS_CFLAGS], [ ntp_os_cflags="-Ae -Wp,-H18816" ;; esac + ntp_os_cflags="${ntp_os_cflags} -D_HPUX_SOURCE" ;; hpux*) case "$GCC" in @@ -49,6 +50,7 @@ AC_DEFUN([NTP_OS_CFLAGS], [ # use Ansi compiler on HPUX ntp_os_cflags="-Ae" esac + ntp_os_cflags="${ntp_os_cflags} -D_HPUX_SOURCE" ;; irix6*) case "$CC" in diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index 65e02c86c..9426e0a0f 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -3501,8 +3501,6 @@ config_unpeers( unpeer(peer); } - /* Ok, everything done. Free up peer node memory */ - free_node(curr_unpeer); continue; } diff --git a/ntpsnmpd/netsnmp_daemonize.c b/ntpsnmpd/netsnmp_daemonize.c index d4da614ac..43cba8922 100644 --- a/ntpsnmpd/netsnmp_daemonize.c +++ b/ntpsnmpd/netsnmp_daemonize.c @@ -192,7 +192,7 @@ netsnmp_daemonize(int quit_immediately, int stderr_log) { int i = 0; DEBUGMSGT(("daemonize","deamonizing...\n")); -#if HAVE_FORK +#if HAVE_WORKING_FORK /* * Fork to return control to the invoking process and to * guarantee that we aren't a process group leader. @@ -257,7 +257,7 @@ netsnmp_daemonize(int quit_immediately, int stderr_log) } #endif /* !WIN32 */ } -#endif /* HAVE_FORK */ +#endif /* HAVE_WORKING_FORK */ return i; } diff --git a/sntp/configure.ac b/sntp/configure.ac index 348ad4877..61be1b81c 100644 --- a/sntp/configure.ac +++ b/sntp/configure.ac @@ -411,6 +411,59 @@ case "$isc_cv_have_in_port_t" in AC_DEFINE(ISC_PLATFORM_NEEDPORTT, 1, [Declare in_port_t?]) esac +AC_CACHE_CHECK( + [for multicast IP support], + ntp_cv_multicast, + [ + ntp_cv_multicast=no + case "$host" in + i386-sequent-sysv4) + ;; + *) + AC_COMPILE_IFELSE( + AC_LANG_PROGRAM( + [ + #ifdef HAVE_NETINET_IN_H + #include + #endif + ], + [ + struct ip_mreq ipmr; + ipmr.imr_interface.s_addr = 0; + ] + ), + [ntp_cv_multicast=yes], + [] + ) + esac + ] +) + +case "$ntp_cv_multicast" in + yes) + AC_DEFINE(MCAST, 1, [Does the target support multicast IP?]) + AC_CACHE_CHECK( + [[arg type needed for setsockopt() IP*_MULTICAST_LOOP]], + ntp_cv_typeof_ip_multicast_loop, + [ + case "$host" in + *-*-netbsd*|*-*-*linux*) + ntp_cv_typeof_ip_multicast_loop=u_int + ;; + *-*-winnt*) + ntp_cv_typeof_ip_multicast_loop=BOOL + ;; + *) + ntp_cv_typeof_ip_multicast_loop=u_char + esac + ] + ) + AC_DEFINE_UNQUOTED([TYPEOF_IP_MULTICAST_LOOP], + $ntp_cv_typeof_ip_multicast_loop, + [What type to use for setsockopt] + ) +esac + AC_SEARCH_LIBS([inet_ntop], [resolv], , , [-lsocket -lnsl]) AC_CHECK_FUNC(inet_ntop, [], [AC_DEFINE(ISC_PLATFORM_NEEDNTOP, 1, [ISC: provide inet_ntop()])]) AC_CHECK_FUNC(inet_pton, [], [AC_DEFINE(ISC_PLATFORM_NEEDPTON, 1, [ISC: provide inet_pton()])]) diff --git a/sntp/networking.c b/sntp/networking.c index f79bff1d9..9aaff7a1b 100644 --- a/sntp/networking.c +++ b/sntp/networking.c @@ -188,7 +188,12 @@ recv_bcst_data ( setsockopt(rsock, SOL_SOCKET, SO_REUSEADDR, &btrue, sizeof(btrue)); if (IS_IPV4(sas)) { +#ifndef MCAST + return BROADCAST_FAILED; +#else struct ip_mreq mdevadr; + TYPEOF_IP_MULTICAST_LOOP mtrue = 1; + if (bind(rsock, &sas->sa, SOCKLEN(sas)) < 0) { if (ENABLED_OPT(NORMALVERBOSE)) @@ -196,7 +201,7 @@ recv_bcst_data ( } - if (setsockopt(rsock, IPPROTO_IP, IP_MULTICAST_LOOP, &btrue, sizeof(btrue)) < 0) { + if (setsockopt(rsock, IPPROTO_IP, IP_MULTICAST_LOOP, &mtrue, sizeof(mtrue)) < 0) { /* some error message regarding setting up multicast loop */ return BROADCAST_FAILED; } @@ -224,6 +229,7 @@ recv_bcst_data ( return BROADCAST_FAILED; } } +#endif /* MCAST */ } #ifdef ISC_PLATFORM_HAVEIPV6 else if (IS_IPV6(sas)) {