From: mpi Date: Wed, 13 Dec 2017 08:54:59 +0000 (+0000) Subject: Sizes for free in route_output(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c23958a615bbae69c703b2fb33f44705c5017849;p=openbsd Sizes for free in route_output(). From kshe59@zoho.eu. --- diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index e3eda412388..8b87c144601 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.256 2017/12/10 11:25:18 mpi Exp $ */ +/* $OpenBSD: rtsock.c,v 1.257 2017/12/13 08:54:59 mpi Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -706,8 +706,9 @@ route_output(struct mbuf *m, struct socket *so, struct sockaddr *dstaddr, if (!error) { type = rtm->rtm_type; seq = rtm->rtm_seq; - free(rtm, M_RTABLE, 0); + free(rtm, M_RTABLE, len); rtm = rtm_report(rt, type, seq, tableid); + len = rtm->rtm_msglen; } } @@ -725,18 +726,18 @@ route_output(struct mbuf *m, struct socket *so, struct sockaddr *dstaddr, if (route_cb.any_count <= 1) { /* no other listener and no loopback of messages */ fail: - free(rtm, M_RTABLE, 0); + free(rtm, M_RTABLE, len); m_freem(m); return (error); } } if (rtm) { - if (m_copyback(m, 0, rtm->rtm_msglen, rtm, M_NOWAIT)) { + if (m_copyback(m, 0, len, rtm, M_NOWAIT)) { m_freem(m); m = NULL; - } else if (m->m_pkthdr.len > rtm->rtm_msglen) - m_adj(m, rtm->rtm_msglen - m->m_pkthdr.len); - free(rtm, M_RTABLE, 0); + } else if (m->m_pkthdr.len > len) + m_adj(m, len - m->m_pkthdr.len); + free(rtm, M_RTABLE, len); } if (m) route_input(m, so, info.rti_info[RTAX_DST] ?