diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2017-01-25 09:41:46 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2017-01-25 09:41:46 +0000 |
commit | 3419c06b721594e0dac1e52da5d465cebbcd3a73 (patch) | |
tree | 5d89ef5924b621a28d72e4524cf7837e4d1a6a58 /sys | |
parent | 83412cfed8279a5b8d5f7d9b34588dc0079d7bc6 (diff) |
Clear the reference of the original mbuf chain after m_split()'ing
a mbuf and properly intialize m_len.
From FreeBSD via Imre Vadasz.
ok bluhm@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/uipc_mbuf.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 514e7c963ee..1c1e747f01a 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf.c,v 1.239 2016/11/29 10:22:30 jsg Exp $ */ +/* $OpenBSD: uipc_mbuf.c,v 1.240 2017/01/25 09:41:45 mpi Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */ /* @@ -1013,6 +1013,12 @@ m_split(struct mbuf *m0, int len0, int wait) n->m_pkthdr.len -= len0; olen = m0->m_pkthdr.len; m0->m_pkthdr.len = len0; + if (remain == 0) { + n->m_next = m->m_next; + m->m_next = NULL; + n->m_len = 0; + return (n); + } if (m->m_flags & M_EXT) goto extpacket; if (remain > MHLEN) { @@ -1023,8 +1029,10 @@ m_split(struct mbuf *m0, int len0, int wait) (void) m_free(n); m0->m_pkthdr.len = olen; return (NULL); - } else + } else { + n->m_len = 0; return (n); + } } else MH_ALIGN(n, remain); } else if (remain == 0) { |