[Bug 195703] New: Incorrect pre-y2k time retrieval from RTC

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Fri Dec 5 08:29:05 UTC 2014


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=195703

            Bug ID: 195703
           Summary: Incorrect pre-y2k time retrieval from RTC
           Product: Base System
           Version: 10.1-STABLE
          Hardware: i386
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: freebsd-bugs at FreeBSD.org
          Reporter: cs at soi.spb.ru

When booting on old hardware with CMOS clock set before year 2000, initial
system time appears to be in the end of twenty first century. On 32-bit systems
it falls beyond 2038 with interesting consequences.

This regression was introduced in 2006 by r162963 (then it was
sys/i386/isa/clock.c).

Here is the patch to correct this problem on modern systems:

--- /usr/src/sys/x86/isa/atrtc.c        2014-08-14 06:33:26.168778002 +0000
+++ atrtc.c     2014-12-04 10:50:10.597250292 +0000
@@ -354,7 +354,7 @@
 #ifdef USE_RTC_CENTURY
        ct.year += readrtc(RTC_CENTURY) * 100;
 #else
-       ct.year += 2000;
+       ct.year += ( ct.year < 70 ? 2000 : 1900 );
 #endif
        critical_exit();
        /* Set dow = -1 because some clocks don't set it correctly. */

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list