🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.protocols.time.ntp
Article #927

Bug in ntpd.c

#927
From: Kirk Reinholtz
Date: Mon, 10 Jun 1991 15:25
29 lines
1355 bytes
Heres the header of the file with the problem.

static char *rcsid = "$Source: /usr/users/louie/ntp/RCS/ntpd.c,v $ $Revision: 3.4.1.9 $ $Date: 89/05/18 18:30:17 $";
#endif	lint

The error is that drift_comp has a undefined value if there is some
problem with the /etc/ntp.drift file, like for example it has nothing
in it because ntp wasn't up long enough to post anything.  The fix is
to set drift_comp to 0.0 in the "else" part of the validation check.

Heres the code I ended up with:

	if ((fp = fopen(driftcomp_file, "r")) != NULL) {
		if (fscanf(fp, "%lf", &j) == 1 && j > -1.0 && j < 1.0) {
			drift_comp = j;
		} else {
		        drift_comp = 0.0;
			fprintf(stderr,
				"init_ntp: bad drift compensation value\n");
			syslog(LOG_ERR,
			       "init_ntp: bad drift compensation value\n");
		};
		syslog(LOG_INFO,
			"Drift compensation value initialized to %f",drift_comp
		);
		fclose(fp);
	}

Enjoy!
Technical Details
Message-ID: <9106101525.AA04901@fsw348.jpl.nasa.gov>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!agate!ucbvax!FSW348.JPL.NASA.GOV!kirk

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!agate!ucbvax!FSW348.JPL.NASA.GOV!kirk
From: kirk@FSW348.JPL.NASA.GOV (Kirk Reinholtz)
Newsgroups: comp.protocols.time.ntp
Subject: Bug in ntpd.c
Message-ID: <9106101525.AA04901@fsw348.jpl.nasa.gov>
Date: 10 Jun 91 15:25:36 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Distribution: inet
Organization: The Internet
Lines: 29