summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-03-23 04:27:34 +0000
committerAngelos D. Keromytis <angelos@cvs.openbsd.org>2001-03-23 04:27:34 +0000
commit67ac333a03b7a5474e2b9f8b6f52a67215f341c7 (patch)
tree9de8127a4d8ded0391e90965af9e9c167f636678
parent9092ec9079a112d1629951b1850126f1bb539bbf (diff)
Fix slow mbuf leak.
-rw-r--r--sys/netinet/ip_esp.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/sys/netinet/ip_esp.c b/sys/netinet/ip_esp.c
index df0c90f4255..5050c4820eb 100644
--- a/sys/netinet/ip_esp.c
+++ b/sys/netinet/ip_esp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_esp.c,v 1.52 2001/03/15 06:30:59 mickey Exp $ */
+/* $OpenBSD: ip_esp.c,v 1.53 2001/03/23 04:27:33 angelos Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
@@ -1158,13 +1158,26 @@ m_pad(struct mbuf *m, int n)
return NULL;
}
+ /* Check for zero-length trailing mbufs, and find the last one */
+ for (m1 = m0; m1->m_next; m1 = m1->m_next)
+ {
+ if (m1->m_next->m_len != 0)
+ {
+ DPRINTF(("m_pad(): length mismatch (should be %d instead of %d)\n",
+ m->m_pkthdr.len, m->m_pkthdr.len + m1->m_next->m_len));
+ m_freem(m);
+ return NULL;
+ }
+
+ m0 = m1->m_next;
+ }
+
if ((m0->m_flags & M_EXT) ||
(m0->m_data + m0->m_len + pad >= &(m0->m_dat[MLEN])))
{
/*
* Add an mbuf to the chain
*/
-
MGET(m1, M_DONTWAIT, MT_DATA);
if (m1 == 0)
{