summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@cvs.openbsd.org>2004-12-13 12:22:53 +0000
committerDarren Tucker <dtucker@cvs.openbsd.org>2004-12-13 12:22:53 +0000
commit18448f1ff2cbf78ea7e7205d819ac53014332eea (patch)
tree94670f4c7ff716aeb093ff46085ff5f8d842e5e4
parent4d5e5f07d7f26999cd6b36046e6fa2df12a7e739 (diff)
Discard replies with alarm flag set or invalid stratum; ok henning@
-rw-r--r--usr.sbin/ntpd/client.c6
-rw-r--r--usr.sbin/ntpd/ntp.h3
2 files changed, 7 insertions, 2 deletions
diff --git a/usr.sbin/ntpd/client.c b/usr.sbin/ntpd/client.c
index 94a8613ad01..e066d3101b3 100644
--- a/usr.sbin/ntpd/client.c
+++ b/usr.sbin/ntpd/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.47 2004/12/09 20:24:46 mickey Exp $ */
+/* $OpenBSD: client.c,v 1.48 2004/12/13 12:22:52 dtucker Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -198,6 +198,10 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
msg.orgtime.fractionl != p->query->msg.xmttime.fractionl)
return (0);
+ if ((msg.status & LI_ALARM) == LI_ALARM || msg.stratum == 0 ||
+ msg.stratum > NTP_MAXSTRATUM)
+ return (0);
+
/*
* From RFC 2030 (with a correction to the delay math):
*
diff --git a/usr.sbin/ntpd/ntp.h b/usr.sbin/ntpd/ntp.h
index 7da44fca226..1c25e249ea6 100644
--- a/usr.sbin/ntpd/ntp.h
+++ b/usr.sbin/ntpd/ntp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp.h,v 1.10 2004/12/08 15:47:38 mickey Exp $ */
+/* $OpenBSD: ntp.h,v 1.11 2004/12/13 12:22:52 dtucker Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -145,5 +145,6 @@ struct ntp_query {
#define JAN_1970 2208988800UL /* 1970 - 1900 in seconds */
#define NTP_VERSION 4
+#define NTP_MAXSTRATUM 15
#endif /* _NTP_H_ */