H,

Should you put this in, or should I?

Dave

----- Forwarded message # 1:

Received: from copland.udel.edu by huey.udel.edu id aa04014; 4 Jul 96 7:35 EDT
Received: from ren.ee.lbl.gov (ren.ee.lbl.gov [131.243.1.52]) by copland.udel.edu (8.7.5/8.7.3) with ESMTP id HAA12971 for <mills@udel.edu>; Thu, 4 Jul 1996 07:35:04 -0400 (EDT)
Received: by ren.ee.lbl.gov (8.7.1/1.43r)
	id EAA01080; Thu, 4 Jul 1996 04:35:02 -0700 (PDT)
Message-Id: <199607041135.EAA01080@ren.ee.lbl.gov>
To: Dave Mills <mills@udel.edu>
Subject: xntp 3.5f bug report
Date: Thu, 04 Jul 96 04:35:01 PDT
From: Craig Leres <leres@ee.lbl.gov>

If you feed xntpd an empty ntp.drift file (an obvious thing to do when
installing it on a new system), it syslog's some garbage:

    Jul  4 03:43:53 bat xntpd[237]: drift value o^?wpow^Dl invalid

This is because fscanf() returns EOF (aka -1) on end of file. Since
what we're really doing is reading a string, my fix uses fgets().
(Besides, I hate fscanf(); you're never quite sure how much of the
input it actually reads.)

It also seemed like a bug that loop_config() is not called if the drift
file contains garbage. In my case, the first bug was keeping the kernel
pll code from kicking in. My version always calls loop_config().

Context diff appended.

Happy 4th.

		Craig
------
RCS file: RCS/ntp_util.c,v
retrieving revision 1.1
diff -c -r1.1 ntp_util.c
*** /tmp/,RCSt1a15272	Thu Jul  4 04:30:09 1996
--- ntp_util.c	Thu Jul  4 04:30:03 1996
***************
*** 276,296 ****
  			if (errno != ENOENT)
  				syslog(LOG_ERR, "can't open %s: %m",
  				       stats_drift_file);
! 		        loop_config(LOOP_DRIFTCOMP, &old_drift);
! 			break;
! 		}
! 
! 		if (fscanf(fp, "%s", buf) == 0) {
! 			syslog(LOG_ERR, "can't read %s: %m",
! 			       stats_drift_file);
  			(void) fclose(fp);
- 		        loop_config(LOOP_DRIFTCOMP, &old_drift);
- 			break;
- 		}
- 		(void) fclose(fp);
- 		if (!atolfp(buf, &old_drift)) {
- 			syslog(LOG_ERR, "drift value %s invalid", buf);
- 			break;
  		}
  		loop_config(LOOP_DRIFTCOMP, &old_drift);
  		break;
--- 276,290 ----
  			if (errno != ENOENT)
  				syslog(LOG_ERR, "can't open %s: %m",
  				       stats_drift_file);
! 		} else {
! 			errno = 0;
! 			if (fgets(buf, sizeof(buf), fp) == NULL) {
! 				if (errno != 0)
! 					syslog(LOG_ERR, "can't read %s: %m",
! 					    stats_drift_file);
! 			} else if (!atolfp(buf, &old_drift))
! 				syslog(LOG_ERR, "drift value %s invalid", buf);
  			(void) fclose(fp);
  		}
  		loop_config(LOOP_DRIFTCOMP, &old_drift);
  		break;

----- End of forwarded messages
