summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2005-02-11 23:07:22 +0000
committerglebius <glebius@FreeBSD.org>2005-02-11 23:07:22 +0000
commitb8a36d0c630d4c447ab50cc3cc8fcb5e349265b4 (patch)
tree4c2939c0c87f2e1cf56b3c67724701fc640a2f4e /sys
parentea01332a61f19e33979ce6e24013461d2ed70c2a (diff)
downloadFreeBSD-src-b8a36d0c630d4c447ab50cc3cc8fcb5e349265b4.zip
FreeBSD-src-b8a36d0c630d4c447ab50cc3cc8fcb5e349265b4.tar.gz
Do not trust ipfw: check m_len always, not only after m_dup.
Submitted by: ru
Diffstat (limited to 'sys')
-rw-r--r--sys/netgraph/ng_ipfw.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/netgraph/ng_ipfw.c b/sys/netgraph/ng_ipfw.c
index 89a0a77..b4b421b 100644
--- a/sys/netgraph/ng_ipfw.c
+++ b/sys/netgraph/ng_ipfw.c
@@ -294,10 +294,13 @@ ng_ipfw_input(struct mbuf **m0, int dir, struct ip_fw_args *fwa, int tee)
m_tag_prepend(m, &ngit->mt);
} else
- if ((m = m_dup(*m0, M_DONTWAIT)) == NULL ||
- (m = m_pullup(m, sizeof(struct ip))) == NULL)
+ if ((m = m_dup(*m0, M_DONTWAIT)) == NULL)
return (ENOMEM); /* which is ignored */
+ if (m->m_len < sizeof(struct ip) &&
+ (m = m_pullup(m, sizeof(struct ip))) == NULL)
+ return(EINVAL);
+
ip = mtod(m, struct ip *);
ip->ip_len = htons(ip->ip_len);
ip->ip_off = htons(ip->ip_off);
OpenPOWER on IntegriCloud