]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hwclock: Check drift value in /etc/adjtime
authorStanislav Brabec <sbrabec@suse.cz>
Mon, 5 May 2014 18:49:49 +0000 (20:49 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 6 May 2014 10:49:56 +0000 (12:49 +0200)
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.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
sys-utils/hwclock.c

index 5e786a84a4ecf4ddb578c7b7a65a94c90308a3e0..fe97fcb751a79f13e7a02d9974176e95e345ec31 100644 (file)
@@ -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 */