summaryrefslogtreecommitdiff
path: root/sys/netinet/ip_esp_old.c
diff options
context:
space:
mode:
authorNiels Provos <provos@cvs.openbsd.org>1998-06-11 14:17:24 +0000
committerNiels Provos <provos@cvs.openbsd.org>1998-06-11 14:17:24 +0000
commitfb5f654af9f4ef9b6ea43138494b64c0d4642020 (patch)
tree79fc80e81333cc453ce401a2d6e72cd5175d2813 /sys/netinet/ip_esp_old.c
parentd7bfe255bf80d92b7cb7c58bd93846987f41b2be (diff)
fix a mbuf chain corruption which happened when m_pullup was called on an
mbuf in the middle of the chain and had to MGET a new one.
Diffstat (limited to 'sys/netinet/ip_esp_old.c')
-rw-r--r--sys/netinet/ip_esp_old.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/sys/netinet/ip_esp_old.c b/sys/netinet/ip_esp_old.c
index ad9f3af08a9..f63fd9a09a6 100644
--- a/sys/netinet/ip_esp_old.c
+++ b/sys/netinet/ip_esp_old.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_esp_old.c,v 1.18 1998/06/03 09:50:22 provos Exp $ */
+/* $OpenBSD: ip_esp_old.c,v 1.19 1998/06/11 14:17:23 provos Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
@@ -296,7 +296,7 @@ esp_old_input(struct mbuf *m, struct tdb *tdb)
u_char *idat, *odat, *ivp, *ivn, *lblk;
struct esp_old *esp;
int ohlen, plen, ilen, i, blks, rest;
- struct mbuf *mi;
+ struct mbuf *mi, *mo;
xd = (struct esp_old_xdata *) tdb->tdb_xdata;
@@ -402,7 +402,7 @@ esp_old_input(struct mbuf *m, struct tdb *tdb)
}
do {
- mi = mi->m_next;
+ mi = (mo = mi)->m_next;
if (mi == NULL)
panic("esp_old_output(): bad chain (i)\n");
} while (mi->m_len == 0);
@@ -416,6 +416,11 @@ esp_old_input(struct mbuf *m, struct tdb *tdb)
espstat.esps_hdrops++;
return NULL;
}
+ /*
+ * m_pullup was not called at the beginning of the chain
+ * but might return a new mbuf, link it into the chain.
+ */
+ mo->m_next = mi;
}
ilen = mi->m_len;
@@ -570,7 +575,7 @@ esp_old_output(struct mbuf *m, struct sockaddr_encap *gw, struct tdb *tdb,
struct ip *ip, ipo;
int i, ilen, ohlen, nh, rlen, plen, padding, rest;
u_int32_t spi;
- struct mbuf *mi;
+ struct mbuf *mi, *mo;
u_char *pad, *idat, *odat, *ivp;
u_char iv[ESP_3DES_IVS], blk[ESP_3DES_IVS], opts[40];
int iphlen, blks;
@@ -675,7 +680,7 @@ esp_old_output(struct mbuf *m, struct sockaddr_encap *gw, struct tdb *tdb,
}
do {
- mi = mi->m_next;
+ mi = (mo = mi)->m_next;
if (mi == NULL)
panic("esp_old_output(): bad chain (i)\n");
} while (mi->m_len == 0);
@@ -688,6 +693,11 @@ esp_old_output(struct mbuf *m, struct sockaddr_encap *gw, struct tdb *tdb,
tdb->tdb_dst, ntohl(tdb->tdb_spi)));
return ENOBUFS;
}
+ /*
+ * m_pullup was not called at the beginning of the chain
+ * but might return a new mbuf, link it into the chain.
+ */
+ mo->m_next = mi;
}
ilen = mi->m_len;