]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2821] minor build issues
authorJuergen Perlinger <perlinger@ntp.org>
Sat, 7 Apr 2018 08:03:14 +0000 (10:03 +0200)
committerJuergen Perlinger <perlinger@ntp.org>
Sat, 7 Apr 2018 08:03:14 +0000 (10:03 +0200)
 + bug fixes

bk: 5ac87b42mWZYQLb427nbu5maUSXbDQ

13 files changed:
ChangeLog
libntp/ntp_calendar.c
ntpd/ntp_config.c
ntpd/ntp_control.c
ntpd/ntp_io.c
ntpd/rc_cmdlength.c
ntpd/refclock_datum.c
ntpd/refclock_gpsdjson.c
ntpd/refclock_jupiter.c
ntpd/refclock_true.c
ntpdc/ntpdc.c
ntpq/ntpq-subs.c
ntpq/ntpq.c

index dcfa59c07f3fb687e22c57016ce0cd382df674e5..7f96d7c71f42a3e88d83d1045ca0d630fa438e8a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+---
+* [Bug 2821] minor build issues <perlinger@ntp.org>
+ - applied patches by Christos Zoulas, including real bug fixes
+
 ---
 (4.2.8p11) 2018/02/27 Released by Harlan Stenn <stenn@ntp.org>
 
index a550d5d3a2c7d27c333cbac1d344dda57523f373..f8b7db4ea501f62b06daad4b968774a10c7a3b61 100644 (file)
@@ -1873,7 +1873,7 @@ basedate_eval_string(
                goto buildstamp;
        }
 
-       rc = scanf(str, "%lu%n", &ned, &nc);
+       rc = sscanf(str, "%lu%n", &ned, &nc);
        if (rc == 1 && (size_t)nc == sl) {
                if (ned <= INT32_MAX)
                        return (int32_t)ned;
index 003b1534a9c42634d046f7c710757e4fc9111a57..7fb7b623a26046527bbbcbf256ea2093963bc721 100644 (file)
@@ -364,7 +364,7 @@ static u_int32 get_match(const char *, struct masks *);
 static u_int32 get_logmask(const char *);
 static int/*BOOL*/ is_refclk_addr(const address_node * addr);
 
-static void    appendstr(char *, size_t, char *);
+static void    appendstr(char *, size_t, const char *);
 
 
 #ifndef SIM
@@ -5463,7 +5463,7 @@ static void
 appendstr(
        char *string,
        size_t s,
-       char *new
+       const char *new
        )
 {
        if (*string != '\0') {
index d98f6aa5088636c8571e068b31eec87730d560d4..9a4273271157a8fcbf8faf66629653449d480541 100644 (file)
@@ -1110,7 +1110,7 @@ save_config(
         */
        prc = snprintf(fullpath, sizeof(fullpath), "%s%s",
                       saveconfigdir, filename);
-       if (prc < 0 || prc >= sizeof(fullpath)) {
+       if (prc < 0 || (size_t)prc >= sizeof(fullpath)) {
                ctl_printf("saveconfig exceeded maximum path length (%u)",
                           (u_int)sizeof(fullpath));
                ctl_flushpkt(0);
@@ -1127,8 +1127,8 @@ save_config(
                fptr = fdopen(fd, "w");
 
        if (NULL == fptr || -1 == dump_all_config_trees(fptr, 1)) {
-               ctl_printf("Unable to save configuration to file '%s': %m",
-                          filename);
+               ctl_printf("Unable to save configuration to file '%s': %s",
+                          filename, strerror(errno));
                msyslog(LOG_ERR,
                        "saveconfig %s from %s failed", filename,
                        stoa(&rbufp->recv_srcadr));
@@ -1677,7 +1677,7 @@ ctl_putuint(
        int  rc;
 
        rc = snprintf(buffer, sizeof(buffer), "%lu", uval);
-       INSIST(rc >= 0 && rc < sizeof(buffer));
+       INSIST(rc >= 0 && (size_t)rc < sizeof(buffer));
        ctl_putunqstr(tag, buffer, rc);
 }
 
@@ -1764,7 +1764,7 @@ ctl_putint(
        int  rc;
        
        rc = snprintf(buffer, sizeof(buffer), "%ld", ival);
-       INSIST(rc >= 0 && rc < sizeof(buffer));
+       INSIST(rc >= 0 && (size_t)rc < sizeof(buffer));
        ctl_putunqstr(tag, buffer, rc);
 }
 
@@ -1878,7 +1878,7 @@ ctl_printf(
        va_start(va, fmt);
        rc = vsnprintf(fmtbuf, sizeof(fmtbuf), fmt, va);
        va_end(va);
-       if (rc < 0 || rc >= sizeof(fmtbuf))
+       if (rc < 0 || (size_t)rc >= sizeof(fmtbuf))
                strcpy(fmtbuf + sizeof(fmtbuf) - strlen(ellipsis) - 1,
                       ellipsis);
        ctl_putdata(fmtbuf, strlen(fmtbuf), 0);
index ed5f0dcaff40faf95c00b9192c3a1f45aa0c20e0..af19931e49437ddbe35694213048a4e0a03dbc36 100644 (file)
@@ -1612,6 +1612,34 @@ set_wildcard_reuse(
 }
 #endif /* OS_NEEDS_REUSEADDR_FOR_IFADDRBIND */
 
+static isc_boolean_t
+check_flags(
+       sockaddr_u *psau,
+       const char *name,
+       u_int32 flags
+       )
+{
+#if defined(SIOCGIFAFLAG_IN)
+       struct ifreq ifr;
+       int fd;
+
+       if (psau->sa.sa_family != AF_INET)
+               return ISC_FALSE;
+       if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+               return ISC_FALSE;
+       ZERO(ifr);
+       memcpy(&ifr.ifr_addr, &psau->sa, sizeof(ifr.ifr_addr));
+       strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+       if (ioctl(fd, SIOCGIFAFLAG_IN, &ifr) < 0) {
+               close(fd);
+               return ISC_FALSE;
+       }
+       close(fd);
+       if ((ifr.ifr_addrflags & flags) != 0)
+               return ISC_TRUE;
+#endif /* SIOCGIFAFLAG_IN */
+       return ISC_FALSE;
+}
 
 static isc_boolean_t
 check_flags6(
@@ -1661,19 +1689,32 @@ is_valid(
        const char *name
        )
 {
-       u_int32 flags6;
+       u_int32 flags;
 
-       flags6 = 0;
+       flags = 0;
+       switch (psau->sa.sa_family) {
+       case AF_INET:
+#ifdef IN_IFF_DETACHED
+               flags |= IN_IFF_DETACHED;
+#endif
+#ifdef IN_IFF_TENTATIVE
+               flags |= IN_IFF_TENTATIVE;
+#endif
+               return check_flags(psau, name, flags) ? ISC_FALSE : ISC_TRUE;
+       case AF_INET6:
 #ifdef IN6_IFF_DEPARTED
-       flags6 |= IN6_IFF_DEPARTED;
+               flags |= IN6_IFF_DEPARTED;
 #endif
 #ifdef IN6_IFF_DETACHED
-       flags6 |= IN6_IFF_DETACHED;
+               flags |= IN6_IFF_DETACHED;
 #endif
 #ifdef IN6_IFF_TENTATIVE
-       flags6 |= IN6_IFF_TENTATIVE;
+               flags |= IN6_IFF_TENTATIVE;
 #endif
-       return check_flags6(psau, name, flags6) ? ISC_FALSE : ISC_TRUE;
+               return check_flags6(psau, name, flags) ? ISC_FALSE : ISC_TRUE;
+       default:
+               return ISC_FALSE;
+       }
 }
 
 /*
index 922312e62a7bafcc55030c7089b519a1c63e0ff9..240fa0afbbdd6713607060e7034c75ec80c559f9 100644 (file)
@@ -5,6 +5,8 @@
 # include <unistd.h>
 #endif
 
+// XXX: Move to header.
+size_t remoteconfig_cmdlength( const char *, const char *);
 
 /* Bug 2853 */
 /* evaluate the length of the command sequence. This breaks at the first
index 9795cfadaab284986a215325dddd445b4f5d5cef..09d72c6af4922b88af2f968f8b9c604abdffb8ac 100644 (file)
@@ -485,7 +485,8 @@ datum_pts_receive(
        struct recvbuf *rbufp
        )
 {
-       int i, nb;
+       int i;
+       size_t nb;
        l_fp tstmp;
        struct peer *p;
        struct datum_pts_unit *datum_pts;
index c2d41ff07f173549b333f602dc7fdd5cca30cf7f..78a4fc82fcc9d3256ae5d77b0d83a685a14f1657 100644 (file)
@@ -1136,7 +1136,7 @@ json_token_skip(
        const json_ctx * ctx,
        tok_ref          tid)
 {
-       if (tid >= 0 && (u_int)tid < ctx->ntok) {
+       if (tid >= 0 && tid < ctx->ntok) {
                int len = ctx->tok[tid].size;
                /* For arrays and objects, the size is the number of
                 * ITEMS in the compound. Thats the number of objects in
@@ -1164,7 +1164,7 @@ json_token_skip(
                /* The next condition should never be true, but paranoia
                 * prevails...
                 */
-               if (tid < 0 || (u_int)tid > ctx->ntok)
+               if (tid < 0 || tid > ctx->ntok)
                        tid = ctx->ntok;
        }
        return tid;
index 84d089d2dd45eff43d451ef36080910e3144fb7a..dbed272467ed8d51d768b7a58d993f1f831528fc 100644 (file)
@@ -139,8 +139,7 @@ static      void    jupiter_canmsg  (struct instance *, u_int);
 static u_short jupiter_cksum   (u_short *, u_int);
 static int     jupiter_config  (struct instance *);
 static void    jupiter_debug   (struct peer *, const char *,
-                                const char *, ...)
-                       __attribute__ ((format (printf, 3, 4)));
+                                const char *, ...) NTP_PRINTF(3, 4);
 static const char *    jupiter_parse_t (struct instance *, u_short *);
 static const char *    jupiter_parse_gpos      (struct instance *, u_short *);
 static void    jupiter_platform        (struct instance *, u_int);
index 2799f3ee5dee8b85512c7e1637868a8c3d04c31a..35901392da0e420ba572fd283a24588b57556fd3 100644 (file)
@@ -640,7 +640,7 @@ true_send(
                size_t len = strlen(cmd);
 
                true_debug(peer, "Send '%s'\n", cmd);
-               if (write(pp->io.fd, cmd, (unsigned)len) != len)
+               if (write(pp->io.fd, cmd, len) != (ssize_t)len)
                        refclock_report(peer, CEVNT_FAULT);
                else
                        pp->polls++;
index 3aeaddc1ae0ccec7582612b42e198b18fab40a57..ce385513b02cfe0c9e6daae4670e209ee5374583 100644 (file)
@@ -944,7 +944,7 @@ sendrequest(
        if (!maclen) {  
                fprintf(stderr, "Key not found\n");
                return 1;
-       } else if (maclen != (int)(info_auth_hashlen + sizeof(keyid_t))) {
+       } else if (maclen != (size_t)(info_auth_hashlen + sizeof(keyid_t))) {
                fprintf(stderr,
                        "%zu octet MAC, %zu expected with %zu octet digest\n",
                        maclen, (info_auth_hashlen + sizeof(keyid_t)),
index acc175d197de6ab3585fa01d923155767b41e881..92968e22a7092b86acc2f53e3d54d51f3909602f 100644 (file)
@@ -2381,7 +2381,7 @@ fetch_nonce(
                return FALSE;
        }
        chars = rsize - (sizeof(nonce_eq) - 1);
-       if (chars >= (int)cb_nonce)
+       if (chars >= cb_nonce)
                return FALSE;
        memcpy(nonce, rdata + sizeof(nonce_eq) - 1, chars);
        nonce[chars] = '\0';
index 17c2f17d38854f9f46e168a8e4f5b46df7154357..913a48496cc3e56f534dbc8996cb835edcce5bc7 100644 (file)
@@ -2504,7 +2504,7 @@ ntp_poll(
 /*
  * showdrefid2str - return a string explanation of the value of drefid
  */
-static char *
+static const char *
 showdrefid2str(void)
 {
        switch (drefid) {
@@ -3321,7 +3321,7 @@ outputarr(
            *bp++ = ' ';
 
        for (i = narr; i > 0; i--) {
-               if (i != narr)
+               if (i != (size_t)narr)
                    *bp++ = ' ';
                cp = lfptoms(lfp, 2);
                len = strlen(cp);
@@ -3639,10 +3639,10 @@ struct hstate {
 static void
 list_md_fn(const EVP_MD *m, const char *from, const char *to, void *arg)
 {
-    size_t       len, n, digest_len;
+    size_t       len, n;
     const char   *name, **seen;
     struct hstate *hstate = arg;
-    char         *cp;
+    const char   *cp;
 
     /* m is MD obj, from is name or alias, to is base name for alias */
     if (!m || !from || to) {
@@ -3651,7 +3651,7 @@ list_md_fn(const EVP_MD *m, const char *from, const char *to, void *arg)
 
     /* Discard MACs that NTP won't accept. */
     /* Keep this consistent with keytype_from_text() in ssl_init.c. */
-    if (EVP_MD_size(m) > (MAX_MAC_LEN - sizeof(keyid_t))) {
+    if ((size_t)EVP_MD_size(m) > (MAX_MAC_LEN - sizeof(keyid_t))) {
         return;
     }