diff options
Diffstat (limited to 'libntp')
| -rw-r--r-- | libntp/Makefile.in | 3 | ||||
| -rw-r--r-- | libntp/atoint.c | 2 | ||||
| -rw-r--r-- | libntp/atolfp.c | 10 | ||||
| -rw-r--r-- | libntp/atouint.c | 2 | ||||
| -rw-r--r-- | libntp/audio.c | 24 | ||||
| -rw-r--r-- | libntp/authkeys.c | 3 | ||||
| -rw-r--r-- | libntp/authreadkeys.c | 8 | ||||
| -rw-r--r-- | libntp/emalloc.c | 2 | ||||
| -rw-r--r-- | libntp/hextoint.c | 2 | ||||
| -rw-r--r-- | libntp/hextolfp.c | 4 | ||||
| -rw-r--r-- | libntp/humandate.c | 4 | ||||
| -rw-r--r-- | libntp/icom.c | 4 | ||||
| -rw-r--r-- | libntp/modetoa.c | 6 | ||||
| -rw-r--r-- | libntp/mstolfp.c | 10 | ||||
| -rw-r--r-- | libntp/ntp_calendar.c | 6 | ||||
| -rw-r--r-- | libntp/ntp_crypto_rnd.c | 17 | ||||
| -rw-r--r-- | libntp/ntp_intres.c | 19 | ||||
| -rw-r--r-- | libntp/ntp_lineedit.c | 13 | ||||
| -rw-r--r-- | libntp/octtoint.c | 2 | ||||
| -rw-r--r-- | libntp/prettydate.c | 14 | ||||
| -rw-r--r-- | libntp/ssl_init.c | 4 | ||||
| -rw-r--r-- | libntp/timetoa.c | 9 |
22 files changed, 86 insertions, 82 deletions
diff --git a/libntp/Makefile.in b/libntp/Makefile.in index 39f287521e15..ca8b13c50ba6 100644 --- a/libntp/Makefile.in +++ b/libntp/Makefile.in @@ -268,6 +268,7 @@ CHUTEST = @CHUTEST@ CONFIG_SHELL = @CONFIG_SHELL@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CPPFLAGS_LIBEVENT = @CPPFLAGS_LIBEVENT@ CPPFLAGS_NTP = @CPPFLAGS_NTP@ CXX = @CXX@ CXXCPP = @CXXCPP@ @@ -302,7 +303,9 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ +LDADD_LIBEVENT = @LDADD_LIBEVENT@ LDADD_LIBNTP = @LDADD_LIBNTP@ +LDADD_LIBUTIL = @LDADD_LIBUTIL@ LDADD_NLIST = @LDADD_NLIST@ LDADD_NTP = @LDADD_NTP@ LDFLAGS = @LDFLAGS@ diff --git a/libntp/atoint.c b/libntp/atoint.c index 1064b366af16..9da8c13c32d6 100644 --- a/libntp/atoint.c +++ b/libntp/atoint.c @@ -35,7 +35,7 @@ atoint( u = 0; while (*cp != '\0') { - if (!isdigit((int)*cp)) + if (!isdigit((unsigned char)*cp)) return 0; if (u > 214748364 || (u == 214748364 && *cp > oflow_digit)) return 0; /* overflow */ diff --git a/libntp/atolfp.c b/libntp/atolfp.c index 4afeb23d33aa..3a65f6bcb2f7 100644 --- a/libntp/atolfp.c +++ b/libntp/atolfp.c @@ -52,7 +52,7 @@ atolfp( * * [spaces][-|+][digits][.][digits][spaces|\n|\0] */ - while (isspace((int)*cp)) + while (isspace((unsigned char)*cp)) cp++; if (*cp == '-') { @@ -63,7 +63,7 @@ atolfp( if (*cp == '+') cp++; - if (*cp != '.' && !isdigit((int)*cp)) + if (*cp != '.' && !isdigit((unsigned char)*cp)) return 0; while (*cp != '\0' && (ind = strchr(digits, *cp)) != NULL) { @@ -72,7 +72,7 @@ atolfp( cp++; } - if (*cp != '\0' && !isspace((int)*cp)) { + if (*cp != '\0' && !isspace((unsigned char)*cp)) { if (*cp++ != '.') return 0; @@ -84,10 +84,10 @@ atolfp( cp++; } - while (isdigit((int)*cp)) + while (isdigit((unsigned char)*cp)) cp++; - if (*cp != '\0' && !isspace((int)*cp)) + if (*cp != '\0' && !isspace((unsigned char)*cp)) return 0; } diff --git a/libntp/atouint.c b/libntp/atouint.c index ab86130dfcdc..0a6163907a51 100644 --- a/libntp/atouint.c +++ b/libntp/atouint.c @@ -28,7 +28,7 @@ atouint( u = 0; while ('\0' != *cp) { - if (!isdigit(*cp)) + if (!isdigit((unsigned char)*cp)) return 0; if (u > 429496729 || (u == 429496729 && *cp >= '6')) return 0; /* overflow */ diff --git a/libntp/audio.c b/libntp/audio.c index 2a56619827f4..6f2262c991f3 100644 --- a/libntp/audio.c +++ b/libntp/audio.c @@ -67,7 +67,7 @@ static struct audio_info info; /* audio device info */ static int ctl_fd; /* audio control file descriptor */ #ifdef PCM_STYLE_SOUND -static void audio_config_read (int, char **, char **); +static void audio_config_read (int, const char **, const char **); static int mixer_name (const char *, int); @@ -114,8 +114,8 @@ mixer_name( static void audio_config_read( int unit, - char **c_dev, /* Control device */ - char **i_dev /* input device */ + const char **c_dev, /* Control device */ + const char **i_dev /* input device */ ) { FILE *fd; @@ -148,12 +148,12 @@ audio_config_read( /* Remove any trailing spaces */ for (i = strlen(line); - i > 0 && isascii((int)line[i - 1]) && isspace((int)line[i - 1]); + i > 0 && isascii((unsigned char)line[i - 1]) && isspace((unsigned char)line[i - 1]); ) line[--i] = '\0'; /* Remove leading space */ - for (cc = line; *cc && isascii((int)*cc) && isspace((int)*cc); cc++) + for (cc = line; *cc && isascii((unsigned char)*cc) && isspace((unsigned char)*cc); cc++) continue; /* Stop if nothing left */ @@ -162,16 +162,16 @@ audio_config_read( /* Uppercase the command and find the arg */ for (ca = cc; *ca; ca++) { - if (isascii((int)*ca)) { - if (islower((int)*ca)) { - *ca = toupper(*ca); - } else if (isspace((int)*ca) || (*ca == '=')) + if (isascii((unsigned char)*ca)) { + if (islower((unsigned char)*ca)) { + *ca = toupper((unsigned char)*ca); + } else if (isspace((unsigned char)*ca) || (*ca == '=')) break; } } /* Remove space (and possible =) leading the arg */ - for (; *ca && isascii((int)*ca) && (isspace((int)*ca) || (*ca == '=')); ca++) + for (; *ca && isascii((unsigned char)*ca) && (isspace((unsigned char)*ca) || (*ca == '=')); ca++) continue; if (!strncmp(cc, "IDEV", 4) && @@ -210,7 +210,7 @@ audio_config_read( */ int audio_init( - char *dname, /* device name */ + const char *dname, /* device name */ int bufsiz, /* buffer size */ int unit /* device unit (0-3) */ ) @@ -227,7 +227,7 @@ audio_init( #endif int fd; int rval; - char *actl = + const char *actl = #ifdef PCM_STYLE_SOUND actl_dev #else diff --git a/libntp/authkeys.c b/libntp/authkeys.c index 7b4427cd2f40..68771ffb339f 100644 --- a/libntp/authkeys.c +++ b/libntp/authkeys.c @@ -517,7 +517,7 @@ MD5auth_setkey( keyid_t keyno, int keytype, const u_char *key, - int len + size_t len ) { symkey * sk; @@ -527,7 +527,6 @@ MD5auth_setkey( DEBUG_ENSURE(keytype <= USHRT_MAX); DEBUG_ENSURE(len < 4 * 1024); - len = max(0, len); /* * See if we already have the key. If so just stick in the * new value. diff --git a/libntp/authreadkeys.c b/libntp/authreadkeys.c index 9b02119d169a..e8ddc942a665 100644 --- a/libntp/authreadkeys.c +++ b/libntp/authreadkeys.c @@ -77,8 +77,8 @@ authreadkeys( int keytype; char buf[512]; /* lots of room for line */ u_char keystr[32]; /* Bug 2537 */ - int len; - int j; + size_t len; + size_t j; /* * Open file. Complain and return if it can't be opened. @@ -181,11 +181,11 @@ authreadkeys( char hex[] = "0123456789abcdef"; u_char temp; char *ptr; - int jlim; + size_t jlim; jlim = min(len, 2 * sizeof(keystr)); for (j = 0; j < jlim; j++) { - ptr = strchr(hex, tolower(token[j])); + ptr = strchr(hex, tolower((unsigned char)token[j])); if (ptr == NULL) break; /* abort decoding */ temp = (u_char)(ptr - hex); diff --git a/libntp/emalloc.c b/libntp/emalloc.c index c49c5c1e1781..6c1c6787ea41 100644 --- a/libntp/emalloc.c +++ b/libntp/emalloc.c @@ -86,6 +86,7 @@ estrdup_impl( } +#if 0 #ifndef EREALLOC_CALLSITE void * emalloc(size_t newsz) @@ -93,4 +94,5 @@ emalloc(size_t newsz) return ereallocz(NULL, newsz, 0, FALSE); } #endif +#endif diff --git a/libntp/hextoint.c b/libntp/hextoint.c index d24b5a0bf8a5..980a43f9d899 100644 --- a/libntp/hextoint.c +++ b/libntp/hextoint.c @@ -23,7 +23,7 @@ hextoint( u = 0; while (*cp != '\0') { - if (!isxdigit(*cp)) + if (!isxdigit((unsigned char)*cp)) return 0; if (u & 0xF0000000) return 0; /* overflow */ diff --git a/libntp/hextolfp.c b/libntp/hextolfp.c index 8fbce2e5b863..2bff929dc388 100644 --- a/libntp/hextolfp.c +++ b/libntp/hextolfp.c @@ -30,7 +30,7 @@ hextolfp( * * [spaces]8_hex_digits[.]8_hex_digits[spaces|\n|\0] */ - while (isspace((int)*cp)) + while (isspace((unsigned char)*cp)) cp++; cpstart = cp; @@ -59,7 +59,7 @@ hextolfp( if ((cp - cpstart) < 8 || ind == NULL) return 0; - if (*cp != '\0' && !isspace((int)*cp)) + if (*cp != '\0' && !isspace((unsigned char)*cp)) return 0; lfp->l_ui = dec_i; diff --git a/libntp/humandate.c b/libntp/humandate.c index f88d8d24cb4d..d9d5e89df017 100644 --- a/libntp/humandate.c +++ b/libntp/humandate.c @@ -13,7 +13,7 @@ /* This is used in msyslog.c; we don't want to clutter up the log with the year and day of the week, etc.; just the minimal date and time. */ -char * +const char * humanlogtime(void) { char * bp; @@ -39,7 +39,7 @@ humanlogtime(void) * humantime() -- like humanlogtime() but without date, and with the * time to display given as an argument. */ -char * +const char * humantime( time_t cursec ) diff --git a/libntp/icom.c b/libntp/icom.c index c981d8548418..80700114255e 100644 --- a/libntp/icom.c +++ b/libntp/icom.c @@ -121,17 +121,15 @@ doublefreq( /* returns void */ */ int icom_init( - char *device, /* device name/link */ + const char *device, /* device name/link */ int speed, /* line speed */ int trace /* trace flags */ ) { TTY ttyb; int fd; - int flags; int rc; int saved_errno; - flags = trace; fd = tty_open(device, O_RDWR, 0777); if (fd < 0) return -1; diff --git a/libntp/modetoa.c b/libntp/modetoa.c index b476bc9e90f2..6f13d20580bf 100644 --- a/libntp/modetoa.c +++ b/libntp/modetoa.c @@ -9,7 +9,7 @@ const char * modetoa( - int mode + size_t mode ) { char *bp; @@ -25,9 +25,9 @@ modetoa( "bclient", }; - if (mode < 0 || mode >= COUNTOF(modestrings)) { + if (mode >= COUNTOF(modestrings)) { LIB_GETBUF(bp); - snprintf(bp, LIB_BUFLENGTH, "mode#%d", mode); + snprintf(bp, LIB_BUFLENGTH, "mode#%zu", mode); return bp; } diff --git a/libntp/mstolfp.c b/libntp/mstolfp.c index 1a1a02b5fc46..828b14cfbca8 100644 --- a/libntp/mstolfp.c +++ b/libntp/mstolfp.c @@ -32,7 +32,7 @@ mstolfp( */ bp = buf; cp = str; - while (isspace((int)*cp)) + while (isspace((unsigned char)*cp)) cp++; if (*cp == '-') { @@ -40,7 +40,7 @@ mstolfp( cp++; } - if (*cp != '.' && !isdigit((int)*cp)) + if (*cp != '.' && !isdigit((unsigned char)*cp)) return 0; @@ -48,7 +48,7 @@ mstolfp( * Search forward for the decimal point or the end of the string. */ cpdec = cp; - while (isdigit((int)*cpdec)) + while (isdigit((unsigned char)*cpdec)) cpdec++; /* @@ -86,7 +86,7 @@ mstolfp( if (*cp == '.') { cp++; - while (isdigit((int)*cp)) + while (isdigit((unsigned char)*cp)) *bp++ = (char)*cp++; } *bp = '\0'; @@ -95,7 +95,7 @@ mstolfp( * Check to make sure the string is properly terminated. If * so, give the buffer to the decoding routine. */ - if (*cp != '\0' && !isspace((int)*cp)) + if (*cp != '\0' && !isspace((unsigned char)*cp)) return 0; return atolfp(buf, lfp); } diff --git a/libntp/ntp_calendar.c b/libntp/ntp_calendar.c index e557f4ec682e..94ca0e9ee154 100644 --- a/libntp/ntp_calendar.c +++ b/libntp/ntp_calendar.c @@ -153,7 +153,11 @@ ntpcal_get_build_date( * problem. * */ +#ifdef MKREPRO_DATE + static const char build[] = MKREPRO_TIME "/" MKREPRO_DATE; +#else static const char build[] = __TIME__ "/" __DATE__; +#endif static const char mlist[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; char monstr[4]; @@ -1561,7 +1565,7 @@ isocal_ntp64_to_date( id->year = (uint16_t)ds.hi + 1; /* shift to current */ id->week = (uint8_t )ds.lo + 1; - return (ds.hi >= 0 && ds.hi < 0xFFFFU); + return (ds.hi >= 0 && ds.hi < 0x0000FFFF); } int diff --git a/libntp/ntp_crypto_rnd.c b/libntp/ntp_crypto_rnd.c index 62a808db3447..96348f2e8696 100644 --- a/libntp/ntp_crypto_rnd.c +++ b/libntp/ntp_crypto_rnd.c @@ -22,6 +22,22 @@ #include <openssl/rand.h> int crypto_rand_init = 0; +#else + +# ifndef HAVE_ARC4RANDOM_BUF +static void +arc4random_buf(void *buf, size_t nbytes); + +void +evutil_secure_rng_get_bytes(void *buf, size_t nbytes); + +static void +arc4random_buf(void *buf, size_t nbytes) +{ + evutil_secure_rng_get_bytes(buf, nbytes); + return; +} +# endif #endif /* @@ -85,6 +101,7 @@ ntp_crypto_random_buf( err = ERR_get_error(); err_str = ERR_error_string(err, NULL); /* XXX: Log the error */ + (void)&err_str; return -1; } diff --git a/libntp/ntp_intres.c b/libntp/ntp_intres.c index 2ac70c1a416d..eea88a127378 100644 --- a/libntp/ntp_intres.c +++ b/libntp/ntp_intres.c @@ -684,11 +684,11 @@ blocking_getnameinfo( blocking_gni_resp * gni_resp; size_t octets; size_t resp_octets; - char * host; char * service; char * cp; int rc; time_t time_now; + char host[1024]; gni_req = (void *)((char *)req + sizeof(*req)); @@ -699,19 +699,7 @@ blocking_getnameinfo( * large allocations. We only need room for the host * and service names. */ - NTP_REQUIRE(octets < 1024); - -#ifndef HAVE_ALLOCA - host = emalloc(octets); -#else - host = alloca(octets); - if (NULL == host) { - msyslog(LOG_ERR, - "blocking_getnameinfo unable to allocate %lu octets on stack", - (u_long)octets); - exit(1); - } -#endif + NTP_REQUIRE(octets < sizeof(host)); service = host + gni_req->hostoctets; worker_ctx = get_worker_context(c, gni_req->dns_idx); @@ -793,9 +781,6 @@ blocking_getnameinfo( rc = queue_blocking_response(c, resp, resp_octets, req); if (rc) msyslog(LOG_ERR, "blocking_getnameinfo unable to queue response"); -#ifndef HAVE_ALLOCA - free(host); -#endif return rc; } diff --git a/libntp/ntp_lineedit.c b/libntp/ntp_lineedit.c index c5aad3108614..e3bc0022a292 100644 --- a/libntp/ntp_lineedit.c +++ b/libntp/ntp_lineedit.c @@ -178,23 +178,22 @@ ntp_readline( if (NULL != line) { if (*line) { add_history(line); - *pcount = strlen(line); - } else { - free(line); - line = NULL; } + *pcount = strlen(line); } #endif /* LE_READLINE */ #ifdef LE_EDITLINE cline = el_gets(ntp_el, pcount); - if (NULL != cline && *cline) { + if (NULL != cline) { history(ntp_hist, &hev, H_ENTER, cline); - *pcount = strlen(cline); line = estrdup(cline); - } else + } else if (*pcount == -1) { line = NULL; + } else { + line = estrdup(""); + } #endif /* LE_EDITLINE */ #ifdef LE_NONE diff --git a/libntp/octtoint.c b/libntp/octtoint.c index d189e40c494d..e519601d067e 100644 --- a/libntp/octtoint.c +++ b/libntp/octtoint.c @@ -24,7 +24,7 @@ octtoint( u = 0; while (*cp != '\0') { - if (!isdigit((int)*cp) || *cp == '8' || *cp == '9') + if (!isdigit((unsigned char)*cp) || *cp == '8' || *cp == '9') return 0; if (u >= 0x20000000) return 0; /* overflow */ diff --git a/libntp/prettydate.c b/libntp/prettydate.c index f12129716199..5da5ecc50a69 100644 --- a/libntp/prettydate.c +++ b/libntp/prettydate.c @@ -133,7 +133,7 @@ get_struct_tm( if (--folds < MINFOLD) return NULL; ts += SOLAR_CYCLE_SECS; - } else if (ts >= SOLAR_CYCLE_SECS) { + } else if (ts >= (time_t)SOLAR_CYCLE_SECS) { if (++folds > MAXFOLD) return NULL; ts -= SOLAR_CYCLE_SECS; @@ -157,10 +157,10 @@ common_prettydate( int local ) { - static const char* pfmt[2] = { - "%08lx.%08lx %s, %s %2d %4d %2d:%02d:%02d.%03u", - "%08lx.%08lx [%s, %s %2d %4d %2d:%02d:%02d.%03u UTC]" - }; + static const char pfmt0[] = + "%08lx.%08lx %s, %s %2d %4d %2d:%02d:%02d.%03u"; + static const char pfmt1[] = + "%08lx.%08lx [%s, %s %2d %4d %2d:%02d:%02d.%03u UTC]"; char *bp; struct tm *tm; @@ -186,13 +186,13 @@ common_prettydate( */ struct calendar jd; ntpcal_time_to_date(&jd, &sec); - snprintf(bp, LIB_BUFLENGTH, pfmt[local != 0], + snprintf(bp, LIB_BUFLENGTH, local ? pfmt1 : pfmt0, (u_long)ts->l_ui, (u_long)ts->l_uf, daynames[jd.weekday], months[jd.month-1], jd.monthday, jd.year, jd.hour, jd.minute, jd.second, msec); } else - snprintf(bp, LIB_BUFLENGTH, pfmt[0], + snprintf(bp, LIB_BUFLENGTH, pfmt0, (u_long)ts->l_ui, (u_long)ts->l_uf, daynames[tm->tm_wday], months[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year, tm->tm_hour, diff --git a/libntp/ssl_init.c b/libntp/ssl_init.c index 7f1e9a096b20..a9d1d546dfb8 100644 --- a/libntp/ssl_init.c +++ b/libntp/ssl_init.c @@ -96,13 +96,13 @@ keytype_from_text( LIB_GETBUF(upcased); strlcpy(upcased, text, LIB_BUFLENGTH); for (pch = upcased; '\0' != *pch; pch++) - *pch = (char)toupper(*pch); + *pch = (char)toupper((unsigned char)*pch); key_type = OBJ_sn2nid(upcased); #else key_type = 0; #endif - if (!key_type && 'm' == tolower(text[0])) + if (!key_type && 'm' == tolower((unsigned char)text[0])) key_type = NID_md5; if (!key_type) diff --git a/libntp/timetoa.c b/libntp/timetoa.c index c04d34ea0639..f294e16107f9 100644 --- a/libntp/timetoa.c +++ b/libntp/timetoa.c @@ -57,14 +57,12 @@ format_time_fraction( u_int u; long fraclimit; int notneg; /* flag for non-negative value */ - const char * fmt; ldiv_t qr; DEBUG_REQUIRE(prec != 0); LIB_GETBUF(cp); secs_u = (u_time)secs; - fmt = "-%" UTIME_FORMAT ".%0*ld"; /* check if we need signed or unsigned mode */ notneg = (prec < 0); @@ -92,9 +90,7 @@ format_time_fraction( /* Get the absolute value of the split representation time. */ notneg = notneg || ((time_t)secs_u >= 0); - if (notneg) { - fmt++; /* skip '-' */ - } else { + if (!notneg) { secs_u = ~secs_u; if (0 == frac) secs_u++; @@ -103,7 +99,8 @@ format_time_fraction( } /* finally format the data and return the result */ - snprintf(cp, LIB_BUFLENGTH, fmt, secs_u, prec_u, frac); + snprintf(cp, LIB_BUFLENGTH, "%s%" UTIME_FORMAT ".%0*ld", + notneg? "" : "-", secs_u, prec_u, frac); return cp; } |
