diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2005-04-18 11:06:36 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2005-04-18 11:06:36 +0000 |
commit | ee0c70c0cbf84d4d747a799afb2c6e0a5cd1fb9a (patch) | |
tree | 532dbf3b1b0c17b3729bc9662a2a717c24c4517b /usr.sbin/ntpd/client.c | |
parent | 463ca9bf8355bf3ab49168a65789e763e41e0b44 (diff) |
prevent replies with negative delay from being used, could happen with -s
From: Joerg Sonnenberger <joerg@britannica.bec.de> of dragonfly
Diffstat (limited to 'usr.sbin/ntpd/client.c')
-rw-r--r-- | usr.sbin/ntpd/client.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.sbin/ntpd/client.c b/usr.sbin/ntpd/client.c index 8d7388a37e2..660cd11beee 100644 --- a/usr.sbin/ntpd/client.c +++ b/usr.sbin/ntpd/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.58 2005/03/08 12:31:40 henning Exp $ */ +/* $OpenBSD: client.c,v 1.59 2005/04/18 11:06:35 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -228,6 +228,14 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime) p->reply[p->shift].offset = ((T2 - T1) + (T3 - T4)) / 2; p->reply[p->shift].delay = (T4 - T1) - (T3 - T2); + if (p->reply[p->shift].delay < 0) { + interval = error_interval(); + set_next(p, interval); + log_info("reply from %s: negative delay %f", + log_sockaddr((struct sockaddr *)&p->addr->ss), + p->reply[p->shift].delay); + return (0); + } p->reply[p->shift].error = (T2 - T1) - (T3 - T4); p->reply[p->shift].rcvd = time(NULL); p->reply[p->shift].good = 1; |