2001-05-10 Harlan Stenn <stenn@whimsy.udel.edu>
+ * configure.in: 4.0.99k33
+
+ * ntpd/ntp_proto.c (receive): Validate the source port. Lose
+ NTPv1 support.
+ * ntpd/ntp_loopfilter.c (local_clock): Sanity check sys_poll
+ earlier instead of later.
+ From: Dave Mills.
+
* ntpd/refclock_oncore.c (oncore_msg_any): We don't always have
GETTIMEOFDAY().
#endif
if (!ntp_enable) {
record_loop_stats();
- return(0);
+ return (0);
}
/*
printf("ntpd: time slew %.6fs\n", fp_offset);
}
record_loop_stats();
- exit(0);
+ exit (0);
}
/*
* these actions interact with the command line options.
*/
retval = 0;
+ if (sys_poll > peer->maxpoll)
+ sys_poll = peer->maxpoll;
+ else if (sys_poll < peer->minpoll)
+ sys_poll = peer->minpoll;
clock_frequency = flladj = plladj = 0;
mu = peer->epoch - last_time;
if (fabs(fp_offset) > clock_max && clock_max > 0) {
* and ignore it.
*/
default:
- if (sys_poll > peer->maxpoll)
- sys_poll = peer->maxpoll;
- else if (sys_poll < peer->minpoll)
- sys_poll = peer->minpoll;
allow_panic = TRUE;
if (fabs(fp_offset - last_offset) >
CLOCK_SGATE * oerror && mu <
current_time, ntoa(&rbufp->dstadr->sin),
ntoa(&rbufp->recv_srcadr), restrict_mask);
#endif
- if (restrict_mask & RES_IGNORE) {
+ if (restrict_mask & RES_IGNORE)
return; /* no anything */
+ if (!(SRCPORT(&rbufp->recv_srcadr) == NTP_PORT ||
+ SRCPORT(&rbufp->recv_srcadr) >= IPPORT_RESERVED)) {
+ sys_badlength++;
+ return; /* invalid port */
}
pkt = &rbufp->recv_pkt;
if (PKT_VERSION(pkt->li_vn_mode) == NTP_VERSION) {
sys_oldversionpkt++; /* old version */
} else {
sys_unknownversion++;
- return;
+ return; /* invalid version */
}
if (PKT_MODE(pkt->li_vn_mode) == MODE_PRIVATE) {
if (restrict_mask & RES_NOQUERY)
}
if (rbufp->recv_length < LEN_PKT_NOMAC) {
sys_badlength++;
- return; /* no runt packets */
+ return; /* runt packet */
}
/*
- * Figure out his mode and validate the packet. This has some
- * legacy raunch that probably should be removed. If from NTPv1
- * mode zero, The mode is determined from the source port. If
- * the port number is zero, it is from a symmetric active
- * association; otherwise, it is from a client association. From
- * NTPv2 on, all we do is toss out mode zero packets, since
- * control and private mode packets have already been handled.
+ * Validate mode. Note that NTPv1 is no longer supported.
*/
hismode = (int)PKT_MODE(pkt->li_vn_mode);
- if (PKT_VERSION(pkt->li_vn_mode) == NTP_OLDVERSION && hismode ==
- 0) {
- if (SRCPORT(&rbufp->recv_srcadr) == NTP_PORT)
- hismode = MODE_ACTIVE;
- else
- hismode = MODE_CLIENT;
- } else {
- if (hismode == MODE_UNSPEC) {
- sys_badlength++;
- return; /* invalid mode */
- }
+ if (hismode == MODE_UNSPEC) {
+ sys_badlength++;
+ return; /* invalid mode */
}
/*