A Y2K bug in BSD 2.11
hmmm?
Somewhere close to the year 2000 people started to panic. Computers mostly used only 2 digits to indicate the year. But with that new 2000, things would break of course. Millions, maybe even billions were spend to fix those bugs. It was a lot work but people fixed them all. At least that was what they thought.
what?
But then in 2026, 26 years after the fact, a new bug was found (by me). In NTPd on a PDP-11/70 running BSD 2.11 with at least patchlevel 447 (likely more recent version as well).
how to reproduce?
- connect a PSTI receiver (WWV/WWVH receiver by Traconex) to your PDP-11/70
- make a symlink from the tty on which the PSTI is connected to /dev/radioclock, e.g.
ln -s /dev/tty00 /dev/refclock - add "
server /dev/radioclock PPS_ 1 -6 psti" to /etc/ntp.conf - run "
ntpd -a any -d -d -d -d"
Now if the PSTI receiver still produces the correct output, it could trigger the following debug output in ntp:
offset excessive (system 19126/136, clock 19126/136)Applying this fix solves that:
diff --git a/usr/usr.sbin/ntp/read_psti.c b/usr/usr.sbin/ntp/read_psti.c
index 61417ea..eef6579 100644
--- a/usr/usr.sbin/ntp/read_psti.c
+++ b/usr/usr.sbin/ntp/read_psti.c
@@ -290,22 +290,22 @@ struct timeval **tvpp, **otvpp;
diff = reltime(rtm, millis*1000) - reltime(mtm, mytime.tv_usec);
#ifdef DEBUG
if (debug > 1)
- printf("Clock time: 19%d day %03d %02d:%02d:%02d.%03d diff %.3f\n",
- rtm->tm_year, rtm->tm_yday, rtm->tm_hour,
+ printf("Clock time: %d day %03d %02d:%02d:%02d.%03d diff %.3f\n",
+ rtm->tm_year + 1900, rtm->tm_yday, rtm->tm_hour,
rtm->tm_min, rtm->tm_sec, millis, diff);
#endif DEBUG
if (diff > (90*24*60*60.0) && (nerrors++%ERR_RATE)==0) {
#ifdef DEBUG
if (debug)
- printf("offset excessive (system 19%d/%d, clock 19%d/%d)\n",
- mtm->tm_year, mtm->tm_yday,
- rtm->tm_year, mtm->tm_yday);
+ printf("offset excessive (system %d/%d, clock %d/%d)\n",
+ mtm->tm_year + 1900, mtm->tm_yday,
+ rtm->tm_year + 1900, mtm->tm_yday);
else
#endif DEBUG
- syslog(LOG_ERR, "offset excessive (system 19%d/%d, clock 19%d/%d)\n",
- mtm->tm_year, mtm->tm_yday,
- rtm->tm_year, mtm->tm_yday);
+ syslog(LOG_ERR, "offset excessive (system %d/%d, clock %d/%d)\n",
+ mtm->tm_year + 1900, mtm->tm_yday,
+ rtm->tm_year + 1900, mtm->tm_yday);
return(1);
}
note
It is not entirely clear which version of the PSTI device this is: the stream as decoded by the NTPd from BSD 2.11 looks different from what is specified on the web.