summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2017-02-08 01:28:52 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2017-02-08 01:28:52 +0000
commit4c42d857677695056402c6188f3662835eb7769e (patch)
tree4d593b24e41d2050219a1e930b1c0d8672ff3863 /sys
parent13be88cd4fb1de063b2a1115adbe9d965fce832d (diff)
Test for NULL before dereferencing a pointer not after.
ok krw@
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/ip_mroute.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index 5a6a9dc5b78..6c507267ed9 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_mroute.c,v 1.108 2017/02/01 20:59:47 dhill Exp $ */
+/* $OpenBSD: ip_mroute.c,v 1.109 2017/02/08 01:28:51 jsg Exp $ */
/* $NetBSD: ip_mroute.c,v 1.85 2004/04/26 01:31:57 matt Exp $ */
/*
@@ -948,7 +948,7 @@ del_mfc(struct socket *so, struct mbuf *m)
struct rtentry *rt;
struct mfcctl2 mfcctl2;
int mfcctl_size = sizeof(struct mfcctl);
- struct mfcctl *mp = mtod(m, struct mfcctl *);
+ struct mfcctl *mp;
unsigned int rtableid = inp->inp_rtableid;
splsoftassert(IPL_SOFTNET);
@@ -961,6 +961,8 @@ del_mfc(struct socket *so, struct mbuf *m)
if (m == NULL || m->m_len < mfcctl_size)
return (EINVAL);
+ mp = mtod(m, struct mfcctl *);
+
bcopy(mp, (caddr_t)&mfcctl2, sizeof(*mp));
memset((caddr_t)&mfcctl2 + sizeof(struct mfcctl), 0,
sizeof(mfcctl2) - sizeof(struct mfcctl));