summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/ntpd/ntp_proto.c
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2015-04-07 20:20:24 +0000
committerdelphij <delphij@FreeBSD.org>2015-04-07 20:20:24 +0000
commite5ee1c2b414851b17663cb491e2f2317a0af9bda (patch)
tree0fb07d612e2cdc3639727807b31799e6a7842bd4 /contrib/ntp/ntpd/ntp_proto.c
parent788993fc41f2549c7ca282a9e1bc3ca4dd88596e (diff)
downloadFreeBSD-src-e5ee1c2b414851b17663cb491e2f2317a0af9bda.zip
FreeBSD-src-e5ee1c2b414851b17663cb491e2f2317a0af9bda.tar.gz
Improve patch for SA-15:04.igmp to solve a potential buffer overflow.
Fix multiple vulnerabilities of ntp. [SA-15:07] Fix bsdinstall(8) insecure default GELI keyfile permissions. [SA-15:08] Fix Denial of Service with IPv6 Router Advertisements. [SA-15:09]
Diffstat (limited to 'contrib/ntp/ntpd/ntp_proto.c')
-rw-r--r--contrib/ntp/ntpd/ntp_proto.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/contrib/ntp/ntpd/ntp_proto.c b/contrib/ntp/ntpd/ntp_proto.c
index 179e118..12619b0 100644
--- a/contrib/ntp/ntpd/ntp_proto.c
+++ b/contrib/ntp/ntpd/ntp_proto.c
@@ -459,7 +459,7 @@ receive(
while (has_mac > 0) {
int temp;
- if (has_mac % 4 != 0 || has_mac < 0) {
+ if (has_mac % 4 != 0 || has_mac < MIN_MAC_LEN) {
sys_badlength++;
return; /* bad MAC length */
}
@@ -483,6 +483,13 @@ receive(
return; /* bad MAC length */
}
}
+ /*
+ * If has_mac is < 0 we had a malformed packet.
+ */
+ if (has_mac < 0) {
+ sys_badlength++;
+ return; /* bad length */
+ }
#ifdef OPENSSL
pkeyid = tkeyid = 0;
#endif /* OPENSSL */
@@ -942,12 +949,9 @@ receive(
}
/*
- * Update the origin and destination timestamps. If
- * unsynchronized or bogus abandon ship. If the crypto machine
+ * If unsynchronized or bogus abandon ship. If the crypto machine
* breaks, light the crypto bit and plaint the log.
*/
- peer->org = p_xmt;
- peer->rec = rbufp->recv_time;
if (peer->flash & PKT_TEST_MASK) {
#ifdef OPENSSL
if (crypto_flags && (peer->flags & FLAG_SKEY)) {
@@ -978,10 +982,11 @@ receive(
* versions. If symmetric modes, return a crypto-NAK. The peer
* should restart the protocol.
*/
- } else if (!AUTH(peer->keyid || (restrict_mask & RES_DONTTRUST),
- is_authentic)) {
+ } else if (!AUTH(peer->keyid || has_mac ||
+ (restrict_mask & RES_DONTTRUST), is_authentic)) {
peer->flash |= TEST5;
- if (hismode == MODE_ACTIVE || hismode == MODE_PASSIVE)
+ if (has_mac &&
+ (hismode == MODE_ACTIVE || hismode == MODE_PASSIVE))
fast_xmit(rbufp, MODE_ACTIVE, 0, restrict_mask);
return; /* bad auth */
}
@@ -989,7 +994,12 @@ receive(
/*
* That was hard and I am sweaty, but the packet is squeaky
* clean. Get on with real work.
+ *
+ * Update the origin and destination timestamps.
*/
+ peer->org = p_xmt;
+ peer->rec = rbufp->recv_time;
+
peer->received++;
peer->timereceived = current_time;
if (is_authentic == AUTH_OK)
OpenPOWER on IntegriCloud