From: Juergen Perlinger Date: Thu, 12 Oct 2017 10:51:50 +0000 (+0200) Subject: [Bug 3438] (ntpq) Negative values and values > 999 days in... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec6e5a24878c4f8ea3779818c8df2179c88b7a84;p=thirdparty%2Fntp.git [Bug 3438] (ntpq) Negative values and values > 999 days in... - make sure negative values are curbed and excessive days are converted to years bk: 59df4946w6Lo3j46O3tGbqJrmcZqJQ --- diff --git a/ChangeLog b/ChangeLog index a1a1cfae4..7578bdb73 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +--- +* [Bug 3438] Negative values and values > 999 days in... + - applied patch by ggarvey (with minor mods) + --- (4.2.8p10-win-beta1) 2017/03/21 Released by Harlan Stenn (4.2.8p10) diff --git a/ntpq/ntpq-subs.c b/ntpq/ntpq-subs.c index 08f9d426a..ed19a1523 100644 --- a/ntpq/ntpq-subs.c +++ b/ntpq/ntpq-subs.c @@ -1452,6 +1452,8 @@ when( else return 0; + if (ts->l_ui < lasttime->l_ui) + return -1; return (ts->l_ui - lasttime->l_ui); } @@ -1490,7 +1492,14 @@ prettyinterval( } diff = (diff + 11) / 24; - snprintf(buf, cb, "%ldd", diff); + if (diff <= 999) { + snprintf(buf, cb, "%ldd", diff); + return buf; + } + + /* years are only approximated... */ + diff = (long)floor(diff / 365.25 + 0.5); + snprintf(buf, cb, "%ldy", diff); return buf; }