summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2019-10-25 17:35:58 +0200
committerDenys Vlasenko2019-10-25 17:35:58 +0200
commitd6ff27de153c8f9361de13f75c7f7ed319044f7c (patch)
tree1ffcd41b5181b5bae163750f075102817e7051f0
parentb4ad1d86b62090fed831e074a3c154af43cd66ce (diff)
downloadbusybox-d6ff27de153c8f9361de13f75c7f7ed319044f7c.zip
busybox-d6ff27de153c8f9361de13f75c7f7ed319044f7c.tar.gz
ntpd: abs(tmx.offset) was truncating a "long" typed value
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/ntpd.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 47410c2..e11160a 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -1876,9 +1876,11 @@ update_local_clock(peer_t *p)
//15:31:53.473 update from:<IP> offset:+0.000007 delay:0.158142 jitter:0.010922 clock drift:+9.343ppm tc:6
//15:32:58.902 update from:<IP> offset:-0.000728 delay:0.158222 jitter:0.009454 clock drift:+9.298ppm tc:6
/*
- * This expression would choose MIN_FREQHOLD + 8 in the above example.
+ * This expression would choose MIN_FREQHOLD + 8 in the above example
+ * (off_065 is +1 for each 0.065536 seconds of offset).
*/
- G.FREQHOLD_cnt = 1 + MIN_FREQHOLD + ((unsigned)(abs(tmx.offset)) >> 16);
+ unsigned off_065 = abs((int)(tmx.offset >> 16));
+ G.FREQHOLD_cnt = 1 + MIN_FREQHOLD + off_065;
}
G.FREQHOLD_cnt--;
tmx.status |= STA_FREQHOLD;