From: Harlan Stenn Date: Thu, 13 Oct 2016 08:24:48 +0000 (-0700) Subject: [Bug 3102] Zero origin issues X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e25fbe2709656c725496ac1d64e5f1b55e3c4b2;p=thirdparty%2Fntp.git [Bug 3102] Zero origin issues bk: 57ff44d0W6suoUHdd2ZvRM3z87j2QA --- diff --git a/ChangeLog b/ChangeLog index 494dae3f5..8b286578b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,7 @@ - implemented Miroslav Lichvars suggestion to skip interface updates based on incoming packets * [Bug 3116] unit tests for NTP time stamp expansion. +* [Bug 3102] Zero origin issues. HStenn. * [Bug 3100] ntpq can't retrieve daemon_version - fixed extended sysvar lookup (bug introduced with bug 3008 fix) * [Bug 3095] Compatibility with openssl 1.1 diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index 513b99f68..b296291b2 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -1645,13 +1645,38 @@ receive( } else if (peer->flip == 0) { INSIST(0 != hisstratum); INSIST(STRATUM_UNSPEC != hisstratum); + if (0) { } else if (L_ISZERO(&p_org)) { + char *action; + + L_CLR(&peer->aorg); + /**/ + switch (hismode) { + /* We allow 0org for: */ + case UCHAR_MAX: + action = "Allow"; + break; + /* We disallow 0org for: */ + case MODE_UNSPEC: + case MODE_ACTIVE: + case MODE_PASSIVE: + case MODE_CLIENT: + case MODE_SERVER: + case MODE_BROADCAST: + action = "Drop"; + peer->bogusorg++; + peer->flash |= TEST2; /* bogus */ + break; + default: + INSIST(!"receive(): impossible hismode"); + break; + } + /**/ msyslog(LOG_INFO, - "receive: Got 0 origin timestamp from %s@%s xmt %#010x.%08x", - hm_str, ntoa(&peer->srcadr), + "receive: %s 0 origin timestamp from %s@%s xmt %#010x.%08x", + action, hm_str, ntoa(&peer->srcadr), ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf)); - L_CLR(&peer->aorg); } else if (!L_ISEQU(&p_org, &peer->aorg)) { /* are there cases here where we should bail? */ /* Should we set TEST2 if we decide to try xleave? */