From: Dave Hart Date: Thu, 6 Jan 2011 20:56:23 +0000 (+0000) Subject: [Bug 1776] sntp mishandles -t/--timeout and -a/--authentication. X-Git-Tag: NTP_4_2_7P113~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae99212fb0c898ac492532774608307d21449164;p=thirdparty%2Fntp.git [Bug 1776] sntp mishandles -t/--timeout and -a/--authentication. Default to silent make rules, override with make V=1 or ./configure --disable-silent-rules. Correct --with-openssl-incdir defaulting with pkg-config. Correct ./build on systems without gtest available. bk: 4d262c77hLM5K3Z80onBfAo3qOdZwg --- diff --git a/ChangeLog b/ChangeLog index 07b5386b2..52f639e7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +* [Bug 1776] sntp mishandles -t/--timeout and -a/--authentication. +* Default to silent make rules, override with make V=1 or ./configure + --disable-silent-rules. +* Correct --with-openssl-incdir defaulting with pkg-config. +* Correct ./build on systems without gtest available. (4.2.7p112) 2011/01/06 Released by Harlan Stenn * [Bug 1773] openssl not detected during ./configure. * [Bug 1774] Segfaults if cryptostats enabled and built without OpenSSL. diff --git a/build b/build index 988bd633b..18e223c7a 100755 --- a/build +++ b/build @@ -171,11 +171,7 @@ CONFIGURE="../configure --cache-file=../config.cache-$IAM$CCSUF $CONFIG_ARGS" "$NICEB" -7 $CONFIGURE "$NICEB" -5 ./config.status && ( cd sntp && "$NICEB" -5 ./config.status ) && - "$NICEB" -14 ${MAKE-make} V=0 && - ( cd sntp/tests && - "$NICEB" -14 ${MAKE-make} V=0 tests ) && - ( cd tests/libntp && - "$NICEB" -14 ${MAKE-make} V=0 tests ) && + "$NICEB" -14 ${MAKE-make} && "$NICEB" -11 ${MAKE-make} check ) > $LOGF 2>&1 diff --git a/configure.ac b/configure.ac index 69a4eea82..903ddf1b5 100644 --- a/configure.ac +++ b/configure.ac @@ -34,10 +34,10 @@ ntp_configure_cache_version=20100916 NTP_CACHEVERSION([main], [$ntp_configure_cache_version]) AM_INIT_AUTOMAKE -dnl AM_SILENT_RULES req. automake 1.11 +dnl AM_SILENT_RULES req. automake 1.11. [yes] defaults V=0 m4_ifdef( [AM_SILENT_RULES], - [AM_SILENT_RULES] + [AM_SILENT_RULES([yes])] ) AC_CANONICAL_BUILD AC_CANONICAL_HOST @@ -223,44 +223,6 @@ case "$ans" in ;; esac -AC_ARG_WITH( - [rpath], - [AS_HELP_STRING( - [--without-rpath], - [s Disable auto-added -R linker paths] - )], - [ans=$withval], - [ans=x] -) -case "$ans" in - no) - need_dash_r= - ;; - yes) - need_dash_r=1 - ;; -esac -# HMS: Why isn't this $build? -# Well, that depends on if we need this for the build toolchain or -# for info in the host executable... -# I still have no idea which way this should go, but nobody has complained. -case "$host" in - *-*-netbsd*) - case "$need_dash_r" in - no) ;; - *) need_dash_r=1 - ;; - esac - ;; - *-*-solaris*) - case "$need_dash_r" in - no) ;; - *) need_dash_r=1 - ;; - esac - ;; -esac - dnl we need to check for cross compile tools for vxWorks here AC_PROG_AWK AC_PROG_MAKE_SET diff --git a/include/ntp_md5.h b/include/ntp_md5.h index 7cb36f89e..7a4019bcb 100644 --- a/include/ntp_md5.h +++ b/include/ntp_md5.h @@ -18,7 +18,7 @@ # include "isc/md5.h" typedef isc_md5_t MD5_CTX; # define MD5Init(c) isc_md5_init(c) -# define MD5Update(c, p, s) isc_md5_update(c, p, s) +# define MD5Update(c, p, s) isc_md5_update(c, (const void *)(p), s) # define MD5Final(d, c) isc_md5_final((c), (d)) /* swapped */ # endif diff --git a/libntp/ssl_init.c b/libntp/ssl_init.c index d4e468a9c..d652b41ae 100644 --- a/libntp/ssl_init.c +++ b/libntp/ssl_init.c @@ -61,10 +61,10 @@ keytype_from_text( size_t *pdigest_len ) { - const u_long max_digest_len = MAX_MAC_LEN - sizeof(keyid_t); int key_type; u_int digest_len; #ifdef OPENSSL + const u_long max_digest_len = MAX_MAC_LEN - sizeof(keyid_t); u_char digest[EVP_MAX_MD_SIZE]; char * upcased; char * pch; diff --git a/libparse/Makefile.am b/libparse/Makefile.am index 3c68697ef..d6b9da394 100644 --- a/libparse/Makefile.am +++ b/libparse/Makefile.am @@ -1,28 +1,17 @@ NULL= AUTOMAKE_OPTIONS = -BUILT_SOURCES = stale_itc_gone +BUILT_SOURCES = noinst_LIBRARIES = @MAKE_LIBPARSE@ @MAKE_LIBPARSE_KERNEL@ EXTRA_LIBRARIES = libparse.a libparse_kernel.a EXTRA_PROGRAMS = parsestreams parsesolaris noinst_PROGRAMS = @MAKE_PARSEKMODULE@ -CLEANFILES = stale_itc_gone +CLEANFILES = K_CFLAGS = -DPARSESTREAM -DNTP_NEED_BOPS # info_trimble.c was mistakenly created in the build directory # previously. It is located in $(srcdir) and any updates must # end up there. -# As a transitional measure, a new target stale_itc_gone has been added -# which removes the stale $(builddir)/info_trimble.c which will be in -# the build directory of those tracking the source changes over time -# while re-using the existing build directory which is not the source -# directory. To ensure that rule fires in each of the commonly several -# build trees sharing a single source tree, stale_itc_gone has been -# added temporarily to BUILT_SOURCES. After a month or so, this -# comment block can be removed, and stale_itc_gone with it. It should -# come out of CLEANFILES (which still needs to be explicitly set, don't -# simply remove the line) and BUILT_SOURCES at the same time the rule -# is removed. libparse_a_SOURCES = parse.c \ parse_conf.c \ @@ -76,10 +65,6 @@ ETAGS_ARGS = Makefile.am EXTRA_DIST = parsesolaris.c parsestreams.c mkinfo_scmd.sed mkinfo_rcmd.sed info_trimble.c -stale_itc_gone: - -[ "$(srcdir)" != "." ] && rm -f info_trimble.c # rid ourselves of leftover from old way - @echo "at most one info_trimble.c in source and build dirs" > $@ - $(srcdir)/info_trimble.c: $(top_srcdir)/include/trimble.h $(srcdir)/Makefile.am $(srcdir)/mkinfo_scmd.sed $(srcdir)/mkinfo_rcmd.sed sed -n -f $(srcdir)/mkinfo_scmd.sed $(top_srcdir)/include/trimble.h > info_trimble.new sed -n -f $(srcdir)/mkinfo_rcmd.sed $(top_srcdir)/include/trimble.h >> info_trimble.new diff --git a/m4/ntp_openssl.m4 b/m4/ntp_openssl.m4 index 192538964..13fd3a1c8 100644 --- a/m4/ntp_openssl.m4 +++ b/m4/ntp_openssl.m4 @@ -1,7 +1,45 @@ dnl ###################################################################### dnl OpenSSL support shared by top-level and sntp/configure.ac AC_DEFUN([NTP_OPENSSL], [ - + +AC_ARG_WITH( + [rpath], + [AS_HELP_STRING( + [--without-rpath], + [s Disable auto-added -R linker paths] + )], + [ans=$withval], + [ans=x] +) +case "$ans" in + no) + need_dash_r= + ;; + yes) + need_dash_r=1 + ;; +esac +# HMS: Why isn't this $build? +# Well, that depends on if we need this for the build toolchain or +# for info in the host executable... +# I still have no idea which way this should go, but nobody has complained. +case "$host" in + *-*-netbsd*) + case "$need_dash_r" in + no) ;; + *) need_dash_r=1 + ;; + esac + ;; + *-*-solaris*) + case "$need_dash_r" in + no) ;; + *) need_dash_r=1 + ;; + esac + ;; +esac + AC_SUBST([OPENSSL]) AC_SUBST([OPENSSL_INC]) AC_SUBST([OPENSSL_LIB]) @@ -31,8 +69,12 @@ case "$ans" in '') ;; *) - pkgans="`$PKG_CONFIG --libs-only-L openssl | sed -e 's/^-L//'`" 2>/dev/null - test -f "${pkgans}/pkgconfig/openssl.pc" && ans="$pkgans" + pkgans=`$PKG_CONFIG --libs-only-L openssl | sed -e 's/^-L//' 2>/dev/null` + # strip trailing whitespace + pkgans=`set $pkgans ; echo $[1]` + if test -f "${pkgans}/pkgconfig/openssl.pc" ; then + ans="$pkgans" + fi ;; esac ;; @@ -63,6 +105,8 @@ case "$ans" in done case "$i" in no) + echo "" + echo "did not find libcrypto and libssl in any of $ans" ans=no OPENSSL_LIB= ;; @@ -97,8 +141,12 @@ case "$ans" in '') ;; *) - pkgans="`$PKG_CONFIG --cflags-only-I openssl | sed -e 's/^-I//'`" 2>/dev/null - test -f "${pkgans}/pkgconfig/openssl.pc" && ans="$pkgans" + pkgans=`$PKG_CONFIG --cflags-only-I openssl | sed -e 's/^-I//' 2>/dev/null` + # strip trailing whitespace + pkgans=`set $pkgans ; echo $[1]` + if test -f "${pkgans}/openssl/evp.h" ; then + ans="$pkgans" + fi ;; esac ;; @@ -114,13 +162,15 @@ esac case "$ans" in no) ;; - *) # look for openssl/opensslconf.h: + *) # look for openssl/evp.h: for i in $ans no do - test -f $i/openssl/opensslconf.h && break + test -f $i/openssl/evp.h && break done case "$i" in no) + echo "" + echo "did not find openssl/evp.h in any of $ans" ans=no OPENSSL_INC= ;; @@ -130,6 +180,7 @@ case "$ans" in esac ;; esac +AS_UNSET([pkgans]) AC_MSG_RESULT([$ans]) AC_MSG_CHECKING([if we will use crypto]) diff --git a/ntpd/ntp_control.c b/ntpd/ntp_control.c index 837337998..6f434d813 100644 --- a/ntpd/ntp_control.c +++ b/ntpd/ntp_control.c @@ -3351,7 +3351,7 @@ send_mru_entry( */ static void send_random_tag_value( - int index + int indx ) { u_long noise; @@ -3365,7 +3365,7 @@ send_random_tag_value( buf[2] = 'a' + noise % 26; noise >>= 5; buf[3] = '.'; - snprintf(&buf[4], sizeof(buf) - 4, "%d", index); + snprintf(&buf[4], sizeof(buf) - 4, "%d", indx); ctl_putuint(buf, noise); } diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index 5e9611020..168517c7f 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -3866,6 +3866,7 @@ findclosestinterface( sockaddr_u addr_dist; sockaddr_u min_dist; + ZERO_SOCK(&min_dist); winner = NULL; for (ep = ep_list; ep != NULL; ep = ep->elink) { diff --git a/ntpd/ntp_peer.c b/ntpd/ntp_peer.c index 5cb2ffa43..dce06e7e1 100644 --- a/ntpd/ntp_peer.c +++ b/ntpd/ntp_peer.c @@ -544,7 +544,7 @@ peer_config( u_int flags, u_char ttl, keyid_t key, - const char * group + const char * ident /* autokey group */ ) { u_char cast_flags; @@ -588,7 +588,7 @@ peer_config( if ((MDF_ACAST | MDF_POOL) & cast_flags) flags &= ~FLAG_PREEMPT; return newpeer(srcadr, hostname, dstadr, hmode, version, - minpoll, maxpoll, flags, cast_flags, ttl, key, group); + minpoll, maxpoll, flags, cast_flags, ttl, key, ident); } /* @@ -785,7 +785,7 @@ newpeer( u_char cast_flags, u_char ttl, keyid_t key, - const char * group + const char *ident ) { struct peer *peer; @@ -914,8 +914,8 @@ newpeer( #endif /* AUTOKEY */ peer->ttl = (u_char)ttl; peer->keyid = key; - if (NULL != group) - peer->ident = estrdup(group); + if (ident != NULL) + peer->ident = estrdup(ident); peer->precision = sys_precision; peer->hpoll = peer->minpoll; if (cast_flags & MDF_ACAST) diff --git a/ntpd/ntp_refclock.c b/ntpd/ntp_refclock.c index c4a7860a0..70fa576ee 100644 --- a/ntpd/ntp_refclock.c +++ b/ntpd/ntp_refclock.c @@ -510,7 +510,7 @@ refclock_sample( if (debug) printf( "refclock_sample: n %d offset %.6f disp %.6f jitter %.6f\n", - n, pp->offset, pp->disp, pp->jitter); + (int)n, pp->offset, pp->disp, pp->jitter); #endif return (int)n; } diff --git a/ntpd/refclock_acts.c b/ntpd/refclock_acts.c index 442a76977..3080343ae 100644 --- a/ntpd/refclock_acts.c +++ b/ntpd/refclock_acts.c @@ -370,7 +370,7 @@ acts_message( char tbuf[BMAX]; int dtr = TIOCM_DTR; - DPRINTF(1, ("acts: %d %s\n", strlen(msg), msg)); + DPRINTF(1, ("acts: %d %s\n", (int)strlen(msg), msg)); /* * What to do depends on the state and the first token in the diff --git a/ntpdate/ntpdate.c b/ntpdate/ntpdate.c index d126a34e3..50e4c7e01 100644 --- a/ntpdate/ntpdate.c +++ b/ntpdate/ntpdate.c @@ -1888,7 +1888,7 @@ input_handler(void) register int n; register struct recvbuf *rb; struct sock_timeval tvzero; - int fromlen; + GETSOCKNAME_SOCKLEN_TYPE fromlen; l_fp ts; int i; #ifdef HAVE_POLL_H diff --git a/ntpdc/ntpdc.c b/ntpdc/ntpdc.c index 2de9bf67b..46ae695af 100644 --- a/ntpdc/ntpdc.c +++ b/ntpdc/ntpdc.c @@ -1527,7 +1527,8 @@ help( for (row = 0; row < rows; row++) { for (word = row; word < words; word += rows) - fprintf(fp, "%-*.*s", col, col-1, list[word]); + fprintf(fp, "%-*.*s", (int)col, + (int)col - 1, list[word]); fprintf(fp, "\n"); } } else { diff --git a/ntpq/ntpq-subs.c b/ntpq/ntpq-subs.c index 3ef3fbb77..a977a2e89 100644 --- a/ntpq/ntpq-subs.c +++ b/ntpq/ntpq-subs.c @@ -1692,7 +1692,7 @@ doprintpeers( else c = flash2[CTL_PEER_STATVAL(rstatus) & 0x3]; if (numhosts > 1) - fprintf(fp, "%-*s ", maxhostlen, currenthost); + fprintf(fp, "%-*s ", (int)maxhostlen, currenthost); if (AF_UNSPEC == af || AF(&srcadr) == af) { if (!have_srchost) strncpy(clock_name, nntohost(&srcadr), @@ -1789,7 +1789,8 @@ dopeers( maxhostlen = strlen(fullname); } if (numhosts > 1) - fprintf(fp, "%-*.*s ", maxhostlen, maxhostlen, "server"); + fprintf(fp, "%-*.*s ", (int)maxhostlen, (int)maxhostlen, + "server"); fprintf(fp, " remote refid st t when poll reach delay offset jitter\n"); if (numhosts > 1) @@ -1877,27 +1878,27 @@ doopeers( for (i = 0; i < numhosts; ++i) { if (getnetnum(chosts[i], &netnum, fullname, af)) - if ((int)strlen(fullname) > maxhostlen) + if (strlen(fullname) > maxhostlen) maxhostlen = strlen(fullname); } if (numhosts > 1) - (void) fprintf(fp, "%-*.*s ", maxhostlen, maxhostlen, "server"); - (void) fprintf(fp, - " remote local st t when poll reach delay offset disp\n"); + fprintf(fp, "%-*.*s ", (int)maxhostlen, (int)maxhostlen, + "server"); + fprintf(fp, + " remote local st t when poll reach delay offset disp\n"); if (numhosts > 1) for (i = 0; i <= maxhostlen; ++i) - (void) fprintf(fp, "="); - (void) fprintf(fp, - "==============================================================================\n"); + fprintf(fp, "="); + fprintf(fp, + "==============================================================================\n"); for (i = 0; i < numassoc; i++) { if (!showall && - !(CTL_PEER_STATVAL(assoc_cache[i].status) - & (CTL_PST_CONFIG|CTL_PST_REACH))) + !(CTL_PEER_STATVAL(assoc_cache[i].status) & + (CTL_PST_CONFIG | CTL_PST_REACH))) continue; - if (!dogetpeers(opeervarlist, (int)assoc_cache[i].assid, fp, af)) { + if (!dogetpeers(opeervarlist, assoc_cache[i].assid, fp, af)) return; - } } return; } @@ -2865,8 +2866,8 @@ mrulist( if (ppentry - sorted != (int)mru_count) { fprintf(stderr, - "mru_count %u should match MRU list depth %d.\n", - mru_count, ppentry - sorted); + "mru_count %u should match MRU list depth %ld.\n", + mru_count, (long)(ppentry - sorted)); free(sorted); goto cleanup_return; } diff --git a/ntpq/ntpq.c b/ntpq/ntpq.c index e0403e10f..d98757710 100644 --- a/ntpq/ntpq.c +++ b/ntpq/ntpq.c @@ -782,7 +782,7 @@ getresponse( for (f = 0; f < numfrags; f++) fprintf(stderr, "%2u: %5d %5d\t%3d octets\n", - f, offsets[f], + (u_int)f, offsets[f], offsets[f] + counts[f], counts[f]); @@ -906,20 +906,16 @@ getresponse( * boundary and no smaller than claimed by rpkt.count */ if (n & 0x3) { - if (debug) - printf("Response packet not padded, " - "size = %d\n", n); + DPRINTF(1, ("Response packet not padded, size = %d\n", + n)); continue; } shouldbesize = (CTL_HEADER_LEN + count + 3) & ~3; if (n < shouldbesize) { - printf("Response packet claims %u octets " - "payload, above %d received\n", - count, - n - CTL_HEADER_LEN - ); + printf("Response packet claims %u octets payload, above %ld received\n", + count, (long)(n - CTL_HEADER_LEN)); return ERR_INCOMPLETE; } @@ -967,9 +963,9 @@ getresponse( printf("Got packet, size = %d\n", n); if ((int)count > (n - CTL_HEADER_LEN)) { if (debug) - printf("Received count of %d octets, " - "data in packet is %d\n", - count, n-CTL_HEADER_LEN); + printf("Received count of %d octets, data in packet is %ld\n", + count, + (long)(n - CTL_HEADER_LEN)); continue; } if (count == 0 && CTL_ISMORE(rpkt.r_m_e_op)) { @@ -1072,8 +1068,8 @@ getresponse( *rsize = offsets[f-1] + counts[f-1]; if (debug) fprintf(stderr, - "%u packets reassembled into response\n", - numfrags); + "%lu packets reassembled into response\n", + (u_long)numfrags); return 0; } } @@ -2086,8 +2082,8 @@ help( for (row = 0; row < rows; row++) { for (word = row; word < words; word += rows) - fprintf(fp, "%-*.*s", col, col-1, - list[word]); + fprintf(fp, "%-*.*s", (int)col, + (int)col - 1, list[word]); fprintf(fp, "\n"); } } else { diff --git a/sntp/configure.ac b/sntp/configure.ac index 76efa6043..1d4d50192 100644 --- a/sntp/configure.ac +++ b/sntp/configure.ac @@ -34,10 +34,10 @@ sntp_configure_cache_version=20100916 NTP_CACHEVERSION([sntp], [$sntp_configure_cache_version]) AM_INIT_AUTOMAKE -dnl AM_SILENT_RULES req. automake 1.11 +dnl AM_SILENT_RULES req. automake 1.11. [yes] defaults V=0 m4_ifdef( [AM_SILENT_RULES], - [AM_SILENT_RULES] + [AM_SILENT_RULES([yes])] ) AC_CANONICAL_BUILD AC_CANONICAL_HOST diff --git a/sntp/main.c b/sntp/main.c index b96a0cab8..7292d3773 100644 --- a/sntp/main.c +++ b/sntp/main.c @@ -109,7 +109,8 @@ sntp_main ( /* Considering employing a variable that prevents functions of doing anything until * everything is initialized properly */ - resc = resolve_hosts((const char **)argv, argc, &resh, ai_fam_pref); + resc = resolve_hosts((const char * const *)argv, argc, &resh, + ai_fam_pref); if (resc < 1) { printf("Unable to resolve hostname(s)\n"); return -1; @@ -120,7 +121,8 @@ sntp_main ( myargv[0] = OPT_ARG(BROADCAST); myargv[1] = NULL; - bcast = resolve_hosts(myargv, 1, &bcastaddr, ai_fam_pref); + bcast = resolve_hosts(myargv, 1, &bcastaddr, + ai_fam_pref); } /* Select a certain ntp server according to simple criteria? For now @@ -202,6 +204,11 @@ handle_pkt ( char addr_buf[INET6_ADDRSTRLEN]; char *p_SNTP_PRETEND_TIME; time_t pretend_time; +#if SIZEOF_TIME_T == 8 + longlong ll; +#else + long l; +#endif if(rpktl > 0) sw_case = 1; @@ -249,14 +256,18 @@ handle_pkt ( p_SNTP_PRETEND_TIME = getenv("SNTP_PRETEND_TIME"); if (p_SNTP_PRETEND_TIME) { + pretend_time = 0; #if SIZEOF_TIME_T == 4 - sscanf(p_SNTP_PRETEND_TIME, "%ld", &pretend_time); + if (1 == sscanf(p_SNTP_PRETEND_TIME, "%ld", &l)) + pretend_time = (time_t)l; #elif SIZEOF_TIME_T == 8 - sscanf(p_SNTP_PRETEND_TIME, "%lld", &pretend_time); + if (1 == sscanf(p_SNTP_PRETEND_TIME, "%lld", &ll)) + pretend_time = (time_t)ll; #else # include "GRONK: unexpected value for SIZEOF_TIME_T" #endif - tv_dst.tv_sec = pretend_time; + if (0 != pretend_time) + tv_dst.tv_sec = pretend_time; } offset_calculation(rpkt, rpktl, &tv_dst, &offset, @@ -366,20 +377,22 @@ on_wire ( register int try; SOCKET sock; struct key *pkt_key = NULL; + long l; int key_id = 0; struct timeval tv_xmt; struct pkt x_pkt; int error, rpktl, handle_pkt_res; - if (ENABLED_OPT(AUTHENTICATION)) { - key_id = (int) OPT_ARG(AUTHENTICATION); + if (ENABLED_OPT(AUTHENTICATION) && + atoint(OPT_ARG(AUTHENTICATION), &l)) { + key_id = l; get_key(key_id, &pkt_key); } - for (try=0; try<5; try++) { + for (try = 0; try < 5; try++) { memset(&r_pkt, 0, sizeof rbuf); - error = GETTIMEOFDAY(&tv_xmt, (struct timezone *)NULL); + error = GETTIMEOFDAY(&tv_xmt, NULL); tv_xmt.tv_sec += JAN_1970; #ifdef DEBUG diff --git a/sntp/networking.c b/sntp/networking.c index 33a5bad01..5d3c6bd39 100644 --- a/sntp/networking.c +++ b/sntp/networking.c @@ -12,10 +12,10 @@ char adr_buf[INET6_ADDRSTRLEN]; */ int resolve_hosts ( - const char **hosts, - int hostc, - struct addrinfo ***res, - int pref_family + const char * const * hosts, + int hostc, + struct addrinfo *** res, + int pref_family ) { register unsigned int a; @@ -168,6 +168,7 @@ recv_bcst_data ( int recv_bytes = 0; int rdy_socks; GETSOCKNAME_SOCKLEN_TYPE ss_len; + long l; struct timeval timeout_tv; fd_set bcst_fd; #ifdef MCAST @@ -243,8 +244,8 @@ recv_bcst_data ( #endif /* ISC_PLATFORM_HAVEIPV6 */ FD_ZERO(&bcst_fd); FD_SET(rsock, &bcst_fd); - if (ENABLED_OPT(TIMEOUT)) - timeout_tv.tv_sec = (int) OPT_ARG(TIMEOUT); + if (ENABLED_OPT(TIMEOUT) && atoint(OPT_ARG(TIMEOUT), &l)) + timeout_tv.tv_sec = l; else timeout_tv.tv_sec = 68; /* ntpd broadcasts every 64s */ timeout_tv.tv_usec = 0; @@ -478,13 +479,14 @@ recvpkt ( int rdy_socks; int pkt_len; sockaddr_u sender; + long l; struct timeval timeout_tv; fd_set recv_fd; FD_ZERO(&recv_fd); FD_SET(rsock, &recv_fd); - if (ENABLED_OPT(TIMEOUT)) - timeout_tv.tv_sec = (int) OPT_ARG(TIMEOUT); + if (ENABLED_OPT(TIMEOUT) && atoint(OPT_ARG(TIMEOUT), &l)) + timeout_tv.tv_sec = l; else timeout_tv.tv_sec = 68; /* ntpd broadcasts every 64s */ timeout_tv.tv_usec = 0; diff --git a/sntp/networking.h b/sntp/networking.h index 0966f5678..900f5b957 100644 --- a/sntp/networking.h +++ b/sntp/networking.h @@ -36,7 +36,8 @@ /* From ntpdate.c */ int is_reachable (struct addrinfo *dst); -int resolve_hosts (const char **hosts, int hostc, struct addrinfo ***res, int pref_family); +int resolve_hosts (const char * const *hosts, int hostc, + struct addrinfo ***res, int pref_family); void create_socket (SOCKET *rsock, sockaddr_u *dest); diff --git a/util/ntp-keygen.c b/util/ntp-keygen.c index 6375ce01c..e3a5518d6 100644 --- a/util/ntp-keygen.c +++ b/util/ntp-keygen.c @@ -243,10 +243,10 @@ main( char *grpkey = NULL; /* identity extension */ int nid; /* X509 digest/signature scheme */ FILE *fstr = NULL; /* file handle */ + char groupbuf[MAXHOSTNAME + 1]; #define iffsw HAVE_OPT(ID_KEY) #endif /* AUTOKEY */ char hostbuf[MAXHOSTNAME + 1]; - char groupbuf[MAXHOSTNAME + 1]; progname = argv[0];