aboutsummaryrefslogtreecommitdiff
path: root/sys/net/bpf.c
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2013-01-24 14:29:31 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2013-01-24 14:29:31 +0000
commited63043b21445f5c0b7e463a21735a039a8789d1 (patch)
tree2b98143547145cbe0c6bc202094d3f11ae309276 /sys/net/bpf.c
parentd30a6b30fccebff7b187454adf8f5de401fb0020 (diff)
downloadsrc-ed63043b21445f5c0b7e463a21735a039a8789d1.tar.gz
src-ed63043b21445f5c0b7e463a21735a039a8789d1.zip
- Utilize m_get2(), accidentially fixing some signedness bugs.
- Return EMSGSIZE in both cases if uio_resid is oversized or undersized. - No need to clear rcvif.
Notes
Notes: svn path=/head/; revision=245878
Diffstat (limited to 'sys/net/bpf.c')
-rw-r--r--sys/net/bpf.c23
1 files changed, 3 insertions, 20 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 9ee196416683..ba31c6681822 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -522,32 +522,15 @@ bpf_movein(struct uio *uio, int linktype, struct ifnet *ifp, struct mbuf **mp,
}
len = uio->uio_resid;
-
- if (len - hlen > ifp->if_mtu)
+ if (len < hlen || len - hlen > ifp->if_mtu)
return (EMSGSIZE);
- if ((unsigned)len > MJUM16BYTES)
+ m = m_get2(M_WAITOK, MT_DATA, M_PKTHDR, len);
+ if (m == NULL)
return (EIO);
-
- if (len <= MHLEN)
- MGETHDR(m, M_WAITOK, MT_DATA);
- else if (len <= MCLBYTES)
- m = m_getcl(M_WAITOK, MT_DATA, M_PKTHDR);
- else
- m = m_getjcl(M_WAITOK, MT_DATA, M_PKTHDR,
-#if (MJUMPAGESIZE > MCLBYTES)
- len <= MJUMPAGESIZE ? MJUMPAGESIZE :
-#endif
- (len <= MJUM9BYTES ? MJUM9BYTES : MJUM16BYTES));
m->m_pkthdr.len = m->m_len = len;
- m->m_pkthdr.rcvif = NULL;
*mp = m;
- if (m->m_len < hlen) {
- error = EPERM;
- goto bad;
- }
-
error = uiomove(mtod(m, u_char *), len, uio);
if (error)
goto bad;