]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1776] sntp mishandles -t/--timeout and -a/--authentication.
authorDave Hart <hart@ntp.org>
Thu, 6 Jan 2011 20:56:23 +0000 (20:56 +0000)
committerDave Hart <hart@ntp.org>
Thu, 6 Jan 2011 20:56:23 +0000 (20:56 +0000)
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

21 files changed:
ChangeLog
build
configure.ac
include/ntp_md5.h
libntp/ssl_init.c
libparse/Makefile.am
m4/ntp_openssl.m4
ntpd/ntp_control.c
ntpd/ntp_io.c
ntpd/ntp_peer.c
ntpd/ntp_refclock.c
ntpd/refclock_acts.c
ntpdate/ntpdate.c
ntpdc/ntpdc.c
ntpq/ntpq-subs.c
ntpq/ntpq.c
sntp/configure.ac
sntp/main.c
sntp/networking.c
sntp/networking.h
util/ntp-keygen.c

index 07b5386b25194d02d0a538a72cb2bb3ffee72264..52f639e7f9964a488597b79b015556e9b9c2438a 100644 (file)
--- 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 <stenn@ntp.org>
 * [Bug 1773] openssl not detected during ./configure.
 * [Bug 1774] Segfaults if cryptostats enabled and built without OpenSSL.
diff --git a/build b/build
index 988bd633b3a1504dd3b991c8a8ae5f018d739c40..18e223c7adf206ab2d04f5b31b07c21e033c4717 100755 (executable)
--- 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
 
index 69a4eea82ba24a3c761df13ef3d68a5e297ae639..903ddf1b57d648541f68709408cccd76451622c0 100644 (file)
@@ -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
index 7cb36f89e345f81275abb5fa8a270284407884a9..7a4019bcb6b226f6e1ddb8ccdedebf5d00b3bdaa 100644 (file)
@@ -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
 
index d4e468a9ce8aab9d415ab80dd2c80cc023d818ba..d652b41ae46b0336e3caa85edfb6e460808c8111 100644 (file)
@@ -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;
index 3c68697ef64c2b7edb158b29a02467a661f35d94..d6b9da394ae1fe417ba7b522afbb91257feafec8 100644 (file)
@@ -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
index 192538964f79e4c9a08dc97eb7ca64ecc33dbd2b..13fd3a1c81b206cad05f73608feafb9409bdce31 100644 (file)
@@ -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])
index 8373379985869d42a02ca22f807e4bc979fc3b0d..6f434d813e4b9338e67a481dcdf23fe8ff31dd16 100644 (file)
@@ -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);
 }
 
index 5e96110203f0ce3d5a4a7a67a91107acf723323d..168517c7fc86b9856d99dcc234e87d7bc18e58f3 100644 (file)
@@ -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) {
index 5cb2ffa4305152bbf498d250ccbd70b325fd0a2b..dce06e7e15ffd718e9aeb2d8cf322b068a1b3e81 100644 (file)
@@ -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)
index c4a7860a030e330cc0c658424fce491f502febdc..70fa576eea370038d26c43231db29d5c14ac2796 100644 (file)
@@ -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;
 }
index 442a76977497ed6eed9c437081b984c27d74e451..3080343ae113a4c43c03fbd2364eff1e2c5b3286 100644 (file)
@@ -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
index d126a34e3b76b8f96eae068479d63ba02e57bcce..50e4c7e01253e105c3d326a3738768013d4dfe69 100644 (file)
@@ -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
index 2de9bf67b731b549772bcfea1892e788d1aee2ba..46ae695afdb4fd89940ba2cb70156ca4f0f058e6 100644 (file)
@@ -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 {
index 3ef3fbb77f86bb4525d634d8ee0b8f2c7d96db1b..a977a2e8992a6686899510d0807f75093d1db956 100644 (file)
@@ -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;
        }
index e0403e10f026173aacfae443f5b41116989609e1..d98757710ed271b83d3d4550480faef25decb1d3 100644 (file)
@@ -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 {
index 76efa6043654a1fec5f099dab64726d85ef1a892..1d4d501924e34a572553e788917148c3c339c3c5 100644 (file)
@@ -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
index b96a0cab8c3b11832d410c00937df505b129a44b..7292d377361876b866fecec50ec44d329ae657f4 100644 (file)
@@ -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
index 33a5bad010baaa6b09dd9d1b8041fd0f419e55b4..5d3c6bd39f23ee98a044282e1955b448bcee0957 100644 (file)
@@ -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;
index 0966f5678e0b1665c80d2e030f39ef1eb13a65cd..900f5b95769789d9ad3d7cf35e01fd32fcb2a9b9 100644 (file)
@@ -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);
 
index 6375ce01c0397f0664380765a752c7da0486f8ab..e3a5518d698f71abf432920b0a1e387b139c1acd 100644 (file)
@@ -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];