Date: Tue, 24 Apr 2012 10:20:24 +0000 (UTC) From: "Alexander V. Chernikov" <melifaro@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r234645 - stable/8/sys/netgraph Message-ID: <201204241020.q3OAKOco041483@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: melifaro Date: Tue Apr 24 10:20:24 2012 New Revision: 234645 URL: http://svn.freebsd.org/changeset/base/234645 Log: MFC r226186 Free mbuf in case when protocol in unknown in ng_ipfw_rcvdata(). This change fixes (theoretically) possible mbuf leak introduced in r225586. Reorder code a bit and change return codes to be more specific Approved by: ae(mentor) Modified: stable/8/sys/netgraph/ng_ipfw.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/netgraph/ng_ipfw.c ============================================================================== --- stable/8/sys/netgraph/ng_ipfw.c Tue Apr 24 09:07:30 2012 (r234644) +++ stable/8/sys/netgraph/ng_ipfw.c Tue Apr 24 10:20:24 2012 (r234645) @@ -242,7 +242,7 @@ ng_ipfw_rcvdata(hook_p hook, item_p item if (m->m_len < sizeof(struct ip) && (m = m_pullup(m, sizeof(struct ip))) == NULL) - return (EINVAL); + return (ENOBUFS); ip = mtod(m, struct ip *); @@ -252,18 +252,14 @@ ng_ipfw_rcvdata(hook_p hook, item_p item #ifdef INET case IPVERSION: ip_input(m); - break; + return (0); #endif #ifdef INET6 case IPV6_VERSION >> 4: ip6_input(m); - break; + return (0); #endif - default: - NG_FREE_M(m); - return (EINVAL); } - return (0); } else { switch (ip->ip_v) { #ifdef INET @@ -277,10 +273,12 @@ ng_ipfw_rcvdata(hook_p hook, item_p item return (ip6_output(m, NULL, NULL, 0, NULL, NULL, NULL)); #endif - default: - return (EINVAL); } } + + /* unknown IP protocol version */ + NG_FREE_M(m); + return (EPROTONOSUPPORT); } static int
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204241020.q3OAKOco041483>