Skip to contentSkip to conversation

hwclock: Check drift value in /etc/adjtime

PATCH Applied Stanislav Brabec 1 participant 1 message May 5, 2014 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 hwclock: Check drift value in /etc/adjtime

Due to bug in older versions of hwclock, /etc/adjtime can contain excessive drift value (up to many years per day). Prevent it from applying.

---
 sys-utils/hwclock.c | 4 ++++
 1 file changed, 4 insertions(+)
sys-utils/hwclock.c +4 -0
index 5e786a8..fe97fcb 100644
@@ -1211,6 +1211,10 @@ do_adjustment(struct adjtime *adjtime_p,
 			printf(_
 			       ("Not setting clock because last adjustment time is zero, "
 				"so history is bad."));
+	} else if (abs(adjtime_p->drift_factor) > MAX_DRIFT) {
+		if (debug)
+		printf(_("Not setting clock because drift factor %f is far too high.\n"),
+		       adjtime_p->drift_factor);
 	} else {
 		int adjustment;
 		/* Number of seconds we must insert in the Hardware Clock */
Signature · 13 lines
1.8.4.5

-- 
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                          e-mail: [email protected]
Lihovarská 1060/12                            tel: +49 911 7405384547
190 00 Praha 9                                 fax:  +420 284 084 001
Czech Republic                                    http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76