]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 3482] Fixes for compilation warnings (ntp_io.c & ntpq-subs.c)
authorJuergen Perlinger <perlinger@ntp.org>
Wed, 11 Apr 2018 16:23:03 +0000 (18:23 +0200)
committerJuergen Perlinger <perlinger@ntp.org>
Wed, 11 Apr 2018 16:23:03 +0000 (18:23 +0200)
bk: 5ace3667Z7aTI6fhyla7ILu7p3tEJw

ChangeLog
ntpq/ntpq-subs.c

index c334512ce76b82337c03c4043a59c5cc7cc3be96..ef56ecc5c7ed1145d4c20eea9d674af866186b7a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
 
 * [Bug 3485] Undefined sockaddr used in error messages in ntp_config.c <perlinger@ntp.org>
   - applied patch by Gerry Garvey
+* [Bug 3482] Fixes for compilation warnings (ntp_io.c & ntpq-subs.c) <perlinger@ntp.org>
+  - applied patch by Gerry Garvey (with mods)
 * [Bug 3480] Refclock sample filter not cleared on clock STEP <perlinger@ntp.org>
   - applied patch by Gerry Garvey
 * [Bug 3479] ctl_putrefid() allows unsafe characters through to ntpq <perlinger@ntp.org>
index 22b77995ac11a345d2969930b82879778af9e10c..e202c6ab3e377f8a7a0153abc1c61948fd5644b1 100644 (file)
@@ -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;