]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
More fuzz bit cleanup from Dave Mills
authorHarlan Stenn <stenn@ntp.org>
Wed, 9 May 2007 20:23:14 +0000 (16:23 -0400)
committerHarlan Stenn <stenn@ntp.org>
Wed, 9 May 2007 20:23:14 +0000 (16:23 -0400)
bk: 46422db2kMnyEXUpuDkeEJkqlnEW2Q

ChangeLog
libntp/systime.c

index 344ac23fc22a7bb8d1ed2f3eaebb5aea64015c5d..b68684c99d8fe989554e0310345fa2cf583497d0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
-* fuzz bit and replay cleanup from Dave Mills.
+* fuzz bit cleanup from Dave Mills.
+* replay cleanup from Dave Mills.
 * [Bug 542] Tolerate missing directory separator at EO statsdir.
 * [Bug 812] ntpd should drop supplementary groups.
 * [Bug 815] Fix warning compiling 4.2.5p22 under Windows with VC6.
index 6a5ad818d02b9bacb76275a34ec16b47837d71e5..b292d64bc2f696b5999b619f2cdf0ef81bb69257 100644 (file)
@@ -71,8 +71,16 @@ get_systime(
        getclock(TIMEOFDAY, &ts);
 # endif
        now->l_i = ts.tv_sec + JAN_1970;
-       ts.tv_nsec |= ntp_random() & 0x3;
-       dtemp = ts.tv_nsec / 1e9;
+       dtemp = sys_residual + ts.tv_nsec / 1e9;
+       if (dtemp >= 1.) {
+               dtemp -= 1.;
+               now->l_i++;
+       } else if (dtemp < 0) {
+               dtemp += 1.;
+               now->l_i--;
+       }
+       now->l_uf = (u_int32)(dtemp * FRAC);
+       now->l_uf |= ntp_random() & 0x3;
 
 #else /* HAVE_CLOCK_GETTIME || HAVE_GETCLOCK */
        struct timeval tv;      /* seconds and microseconds */
@@ -83,24 +91,18 @@ get_systime(
         */
        GETTIMEOFDAY(&tv, NULL);
        now->l_i = tv.tv_sec + JAN_1970;
-       tv.tv_usec |= ntp_random() & 0xfff;
-       dtemp = tv.tv_usec / 1e6;
-
-#endif /* HAVE_CLOCK_GETTIME || HAVE_GETCLOCK */
-
-       /*
-        * Renormalize to seconds past 1900 and fraction.
-        */
-       dtemp += sys_residual;
-       if (dtemp >= 1) {
-               dtemp -= 1;
+       dtemp = sys_residual + tv.tv_usec / 1e6;
+       if (dtemp >= 1.) {
+               dtemp -= 1.;
                now->l_i++;
        } else if (dtemp < 0) {
-               dtemp += 1;
+               dtemp += 1.;
                now->l_i--;
        }
-       dtemp *= FRAC;
-       now->l_uf = (u_int32)dtemp;
+       now->l_uf = (u_int32)(dtemp * FRAC);
+       now->l_uf |= ntp_random() & 0xfff;
+
+#endif /* HAVE_CLOCK_GETTIME || HAVE_GETCLOCK */
 }