From: Harlan Stenn Date: Wed, 9 May 2007 20:23:14 +0000 (-0400) Subject: More fuzz bit cleanup from Dave Mills X-Git-Tag: NTP_4_2_5P30~7^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aba9fcc6a74a82158601ef5aa9c9579ddee45c0a;p=thirdparty%2Fntp.git More fuzz bit cleanup from Dave Mills bk: 46422db2kMnyEXUpuDkeEJkqlnEW2Q --- diff --git a/ChangeLog b/ChangeLog index 344ac23fc..b68684c99 100644 --- 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. diff --git a/libntp/systime.c b/libntp/systime.c index 6a5ad818d..b292d64bc 100644 --- a/libntp/systime.c +++ b/libntp/systime.c @@ -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 */ }