From: Dave Hart Date: Wed, 9 Feb 2011 07:14:49 +0000 (+0000) Subject: Add missing "break;" to ntp_control.c ctl_putsys() for caliberrs, used X-Git-Tag: NTP_4_2_7P129~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f617c7d0966bd8236163be0209d0da3da4ae9df;p=thirdparty%2Fntp.git Add missing "break;" to ntp_control.c ctl_putsys() for caliberrs, used by ntpq -c kerninfo introduced in 4.2.7p104. Fix leak in ntp_control.c read_mru_list(). bk: 4d523ee9-RNRz2dQG8DNanCBLKnflA --- diff --git a/ChangeLog b/ChangeLog index d2fc5d444..ac2d35c2f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +* Add missing "break;" to ntp_control.c ctl_putsys() for caliberrs, used + by ntpq -c kerninfo introduced in 4.2.7p104. +* Fix leak in ntp_control.c read_mru_list(). (4.2.7p128) 2011/01/30 Released by Harlan Stenn * [Bug 1799] ntpq mrv crash. * [Bug 1801] ntpq mreadvar requires prior association caching. diff --git a/include/ntp_assert.h b/include/ntp_assert.h index cbb863a60..ab9b41981 100644 --- a/include/ntp_assert.h +++ b/include/ntp_assert.h @@ -36,7 +36,11 @@ extern void calysto_assert(unsigned char cnd); /* check whether this holds */ #define ALWAYS_INVARIANT(x) calysto_assume(x) #define ALWAYS_ENSURE(x) calysto_assert(x) -# elif defined(__COVERITY__) +/* # elif defined(__COVERITY__) */ +/* + * DH: try letting coverity scan our actual assertion macros, now that + * isc_assertioncallback_t is marked __attribute__ __noreturn__. + */ /* * Coverity has special knowledge that assert(x) terminates the process @@ -46,10 +50,12 @@ extern void calysto_assert(unsigned char cnd); /* check whether this holds */ * that seems to be a reasonable trade-off. */ +/* #define ALWAYS_REQUIRE(x) assert(x) #define ALWAYS_INSIST(x) assert(x) #define ALWAYS_INVARIANT(x) assert(x) #define ALWAYS_ENSURE(x) assert(x) +*/ # else /* neither Coverity nor Calysto */ diff --git a/include/ntp_lists.h b/include/ntp_lists.h index 465782051..4364e6452 100644 --- a/include/ntp_lists.h +++ b/include/ntp_lists.h @@ -106,14 +106,9 @@ #ifndef NTP_LISTS_H #define NTP_LISTS_H +#include "ntp_types.h" /* TRUE and FALSE */ #include "ntp_assert.h" -/* - * For now enable extra debugging code on all builds. Before long, it - * will probably make sense to only include the debugging #ifdef DEBUG - */ -#define NTP_DEBUG_LISTS_H - /* * If list debugging is not enabled, save a little time by not clearing * an entry's link pointer when it is unlinked, as the stale pointer @@ -126,11 +121,6 @@ #define MAYBE_Z_LISTS(p) (p) = NULL #endif -#ifndef TRUE -# define TRUE 1 -# define NTP_LISTS_UNDEF_TRUE -#endif - #define LINK_SLIST(listhead, pentry, nextlink) \ do { \ (pentry)->nextlink = (listhead); \ @@ -158,8 +148,8 @@ do { \ entrytype **ppentry; \ \ ppentry = &(listhead); \ - while (*ppentry != NULL) { \ - if (beforecur) { \ + while (TRUE) { \ + if (NULL == *ppentry || (beforecur)) { \ (pentry)->nextlink = *ppentry; \ *ppentry = (pentry); \ break; \ @@ -171,7 +161,7 @@ do { \ break; \ } \ } \ -} while (0) +} while (FALSE) #define UNLINK_HEAD_SLIST(punlinked, listhead, nextlink) \ do { \ @@ -390,9 +380,4 @@ do { \ } \ } - -#ifdef NTP_LISTS_UNDEF_TRUE -# undef TRUE -#endif - #endif /* NTP_LISTS_H */ diff --git a/ntpd/ntp_control.c b/ntpd/ntp_control.c index fb7881806..75450a4a2 100644 --- a/ntpd/ntp_control.c +++ b/ntpd/ntp_control.c @@ -2111,6 +2111,7 @@ ctl_putsys( ctl_putint, (sys_var[varid].text, ntx.errcnt) ); + break; case CS_K_PPS_JITEXC: CTL_IF_KERNPPS( @@ -3543,9 +3544,11 @@ static void read_mru_list( while (NULL != (v = ctl_getitem(in_parms, &val)) && !(EOV & v->flags)) { - if (!strcmp(nonce_text, v->text)) + if (!strcmp(nonce_text, v->text)) { + if (NULL != pnonce) + free(pnonce); pnonce = estrdup(val); - else if (!strcmp(limit_text, v->text)) + } else if (!strcmp(limit_text, v->text)) sscanf(val, "%u", &limit); else if (!strcmp(mincount_text, v->text)) { if (1 != sscanf(val, "%d", &mincount) || diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index 20a803cbf..8f0b494a4 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -1108,10 +1108,14 @@ add_interface( ? "4" : "6")); + if (INVALID_SOCKET == ep->fd) + return; + /* * select the local address from which to send to multicast. */ switch (AF(&ep->sin)) { + case AF_INET : rc = setsockopt(ep->fd, IPPROTO_IP, IP_MULTICAST_IF, @@ -1122,6 +1126,7 @@ add_interface( "setsockopt IP_MULTICAST_IF %s fails: %m", stoa(&ep->sin)); break; + # ifdef INCLUDE_IPV6_MULTICAST_SUPPORT case AF_INET6 : rc = setsockopt(ep->fd, IPPROTO_IPV6, diff --git a/ntpd/ntp_monitor.c b/ntpd/ntp_monitor.c index cfead2345..48dda53d6 100644 --- a/ntpd/ntp_monitor.c +++ b/ntpd/ntp_monitor.c @@ -161,6 +161,8 @@ mon_reclaim_entry( mon_entry *m ) { + DEBUG_INSIST(NULL != m); + UNLINK_DLIST(m, mru); remove_from_hash(m); ZERO(*m); @@ -451,9 +453,9 @@ ntp_monitor( UNLINK_HEAD_SLIST(mon, mon_free, hash_next); /* Preempt from the MRU list if old enough. */ } else if (ntp_random() / (2. * FRAC) > - (double)oldest_age / mon_age) + (double)oldest_age / mon_age) { return ~(RES_LIMITED | RES_KOD) & flags; - else { + } else { mon_reclaim_entry(oldest); mon = oldest; }