From: Juergen Perlinger Date: Wed, 11 Apr 2018 16:23:03 +0000 (+0200) Subject: [Bug 3482] Fixes for compilation warnings (ntp_io.c & ntpq-subs.c) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e33fb684a880ed75fa89a47bb50deb2bfe4410b4;p=thirdparty%2Fntp.git [Bug 3482] Fixes for compilation warnings (ntp_io.c & ntpq-subs.c) bk: 5ace3667Z7aTI6fhyla7ILu7p3tEJw --- diff --git a/ChangeLog b/ChangeLog index c334512ce..ef56ecc5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * [Bug 3485] Undefined sockaddr used in error messages in ntp_config.c - applied patch by Gerry Garvey +* [Bug 3482] Fixes for compilation warnings (ntp_io.c & ntpq-subs.c) + - applied patch by Gerry Garvey (with mods) * [Bug 3480] Refclock sample filter not cleared on clock STEP - applied patch by Gerry Garvey * [Bug 3479] ctl_putrefid() allows unsafe characters through to ntpq diff --git a/ntpq/ntpq-subs.c b/ntpq/ntpq-subs.c index 22b77995a..e202c6ab3 100644 --- a/ntpq/ntpq-subs.c +++ b/ntpq/ntpq-subs.c @@ -1475,31 +1475,36 @@ prettyinterval( } if (diff <= 2048) { - snprintf(buf, cb, "%ld", diff); + snprintf(buf, cb, "%u", (unsigned int)diff); return buf; } diff = (diff + 29) / 60; if (diff <= 300) { - snprintf(buf, cb, "%ldm", diff); + snprintf(buf, cb, "%um", (unsigned int)diff); return buf; } diff = (diff + 29) / 60; if (diff <= 96) { - snprintf(buf, cb, "%ldh", diff); + snprintf(buf, cb, "%uh", (unsigned int)diff); return buf; } diff = (diff + 11) / 24; if (diff <= 999) { - snprintf(buf, cb, "%ldd", diff); + snprintf(buf, cb, "%ud", (unsigned int)diff); return buf; } /* years are only approximated... */ diff = (long)floor(diff / 365.25 + 0.5); - snprintf(buf, cb, "%ldy", diff); + if (diff <= 999) { + snprintf(buf, cb, "%uy", (unsigned int)diff); + return buf; + } + /* Ok, this amounts to infinity... */ + strlcpy(buf, "INF", cb); return buf; } @@ -1639,9 +1644,12 @@ doprintpeers( l_fp ts; u_long poll_sec; char type = '?'; - char whenbuf[8], pollbuf[8]; char clock_name[LENHOSTNAME]; - + char whenbuf[12], pollbuf[12]; + /* [Bug 3482] formally whenbuf & pollbuf should be able to hold + * a full signed int. Not that we would use that much string + * data for it... + */ get_systime(&ts); have_srchost = FALSE;