From: Juergen Perlinger Date: Sat, 7 Apr 2018 08:03:14 +0000 (+0200) Subject: [Bug 2821] minor build issues X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb236bebe90ed5033c748cc1ea1d93366cbe171a;p=thirdparty%2Fntp.git [Bug 2821] minor build issues + bug fixes bk: 5ac87b42mWZYQLb427nbu5maUSXbDQ --- diff --git a/ChangeLog b/ChangeLog index dcfa59c07..7f96d7c71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +--- +* [Bug 2821] minor build issues + - applied patches by Christos Zoulas, including real bug fixes + --- (4.2.8p11) 2018/02/27 Released by Harlan Stenn diff --git a/libntp/ntp_calendar.c b/libntp/ntp_calendar.c index a550d5d3a..f8b7db4ea 100644 --- a/libntp/ntp_calendar.c +++ b/libntp/ntp_calendar.c @@ -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; diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index 003b1534a..7fb7b623a 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -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') { diff --git a/ntpd/ntp_control.c b/ntpd/ntp_control.c index d98f6aa50..9a4273271 100644 --- a/ntpd/ntp_control.c +++ b/ntpd/ntp_control.c @@ -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); diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index ed5f0dcaf..af19931e4 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -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; + } } /* diff --git a/ntpd/rc_cmdlength.c b/ntpd/rc_cmdlength.c index 922312e62..240fa0afb 100644 --- a/ntpd/rc_cmdlength.c +++ b/ntpd/rc_cmdlength.c @@ -5,6 +5,8 @@ # include #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 diff --git a/ntpd/refclock_datum.c b/ntpd/refclock_datum.c index 9795cfada..09d72c6af 100644 --- a/ntpd/refclock_datum.c +++ b/ntpd/refclock_datum.c @@ -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; diff --git a/ntpd/refclock_gpsdjson.c b/ntpd/refclock_gpsdjson.c index c2d41ff07..78a4fc82f 100644 --- a/ntpd/refclock_gpsdjson.c +++ b/ntpd/refclock_gpsdjson.c @@ -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; diff --git a/ntpd/refclock_jupiter.c b/ntpd/refclock_jupiter.c index 84d089d2d..dbed27246 100644 --- a/ntpd/refclock_jupiter.c +++ b/ntpd/refclock_jupiter.c @@ -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); diff --git a/ntpd/refclock_true.c b/ntpd/refclock_true.c index 2799f3ee5..35901392d 100644 --- a/ntpd/refclock_true.c +++ b/ntpd/refclock_true.c @@ -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++; diff --git a/ntpdc/ntpdc.c b/ntpdc/ntpdc.c index 3aeaddc1a..ce385513b 100644 --- a/ntpdc/ntpdc.c +++ b/ntpdc/ntpdc.c @@ -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)), diff --git a/ntpq/ntpq-subs.c b/ntpq/ntpq-subs.c index acc175d19..92968e22a 100644 --- a/ntpq/ntpq-subs.c +++ b/ntpq/ntpq-subs.c @@ -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'; diff --git a/ntpq/ntpq.c b/ntpq/ntpq.c index 17c2f17d3..913a48496 100644 --- a/ntpq/ntpq.c +++ b/ntpq/ntpq.c @@ -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; }