aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/netgraph/ng_nat.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/netgraph/ng_nat.c b/sys/netgraph/ng_nat.c
index f0784f43ddb8..4b6039d33654 100644
--- a/sys/netgraph/ng_nat.c
+++ b/sys/netgraph/ng_nat.c
@@ -806,11 +806,16 @@ ng_nat_rcvdata(hook_p hook, item_p item )
panic("Corrupted priv->dlt: %u", priv->dlt);
}
+ if (m->m_pkthdr.len < ipofs + sizeof(struct ip))
+ goto send; /* packet too short to hold IP */
+
c = (char *)mtodo(m, ipofs);
ip = (struct ip *)mtodo(m, ipofs);
- KASSERT(m->m_pkthdr.len == ipofs + ntohs(ip->ip_len),
- ("ng_nat: ip_len != m_pkthdr.len"));
+ if (ip->ip_v != IPVERSION)
+ goto send; /* other IP version, let it pass */
+ if (m->m_pkthdr.len < ipofs + ntohs(ip->ip_len))
+ goto send; /* packet too short (i.e. fragmented or broken) */
/*
* We drop packet when: