diff options
author | David Hill <dhill@cvs.openbsd.org> | 2018-03-27 15:03:53 +0000 |
---|---|---|
committer | David Hill <dhill@cvs.openbsd.org> | 2018-03-27 15:03:53 +0000 |
commit | bcfb28af11cf9b8cb367bffd8c8c7817dda2bfb4 (patch) | |
tree | 1da14b2dc4134d64ae4bd25e3f1f637f031cacd4 | |
parent | 79808187c139196fbbd1c232bf5aca743dff4dbf (diff) |
Use memcpy instead of bcopy when the memory does not overlap.
OK deraadt@ florian@
-rw-r--r-- | sys/netinet6/icmp6.c | 14 | ||||
-rw-r--r-- | sys/netinet6/in6_ifattach.c | 8 | ||||
-rw-r--r-- | sys/netinet6/ip6_output.c | 6 |
3 files changed, 14 insertions, 14 deletions
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index 7db5b5c659a..e98ddeb0800 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: icmp6.c,v 1.221 2017/12/14 14:26:50 bluhm Exp $ */ +/* $OpenBSD: icmp6.c,v 1.222 2018/03/27 15:03:52 dhill Exp $ */ /* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */ /* @@ -1075,7 +1075,7 @@ icmp6_reflect(struct mbuf *m, size_t off) if ((m = m_pullup(m, l)) == NULL) return; } - bcopy((caddr_t)&nip6, mtod(m, caddr_t), sizeof(nip6)); + memcpy(mtod(m, caddr_t), &nip6, sizeof(nip6)); } else /* off == sizeof(struct ip6_hdr) */ { size_t l; l = sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr); @@ -1268,7 +1268,7 @@ icmp6_redirect_input(struct mbuf *m, int off) bzero(&sin6, sizeof(sin6)); sin6.sin6_family = AF_INET6; sin6.sin6_len = sizeof(struct sockaddr_in6); - bcopy(&reddst6, &sin6.sin6_addr, sizeof(reddst6)); + memcpy(&sin6.sin6_addr, &reddst6, sizeof(reddst6)); rt = rtalloc(sin6tosa(&sin6), 0, m->m_pkthdr.ph_rtableid); if (rt) { if (rt->rt_gateway == NULL || @@ -1376,9 +1376,9 @@ icmp6_redirect_input(struct mbuf *m, int off) sdst.sin6_family = sgw.sin6_family = ssrc.sin6_family = AF_INET6; sdst.sin6_len = sgw.sin6_len = ssrc.sin6_len = sizeof(struct sockaddr_in6); - bcopy(&redtgt6, &sgw.sin6_addr, sizeof(struct in6_addr)); - bcopy(&reddst6, &sdst.sin6_addr, sizeof(struct in6_addr)); - bcopy(&src6, &ssrc.sin6_addr, sizeof(struct in6_addr)); + memcpy(&sgw.sin6_addr, &redtgt6, sizeof(struct in6_addr)); + memcpy(&sdst.sin6_addr, &reddst6, sizeof(struct in6_addr)); + memcpy(&ssrc.sin6_addr, &src6, sizeof(struct in6_addr)); rtredirect(sin6tosa(&sdst), sin6tosa(&sgw), sin6tosa(&ssrc), &newrt, m->m_pkthdr.ph_rtableid); @@ -1395,7 +1395,7 @@ icmp6_redirect_input(struct mbuf *m, int off) bzero(&sdst, sizeof(sdst)); sdst.sin6_family = AF_INET6; sdst.sin6_len = sizeof(struct sockaddr_in6); - bcopy(&reddst6, &sdst.sin6_addr, sizeof(struct in6_addr)); + memcpy(&sdst.sin6_addr, &reddst6, sizeof(struct in6_addr)); pfctlinput(PRC_REDIRECT_HOST, sin6tosa(&sdst)); } diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index a920342499c..41410046d18 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_ifattach.c,v 1.106 2018/03/13 13:58:03 florian Exp $ */ +/* $OpenBSD: in6_ifattach.c,v 1.107 2018/03/27 15:03:52 dhill Exp $ */ /* $KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $ */ /* @@ -165,7 +165,7 @@ in6_get_hw_ifid(struct ifnet *ifp, struct in6_addr *in6) /* make EUI64 address */ if (addrlen == 8) - bcopy(addr, &in6->s6_addr[8], 8); + memcpy(&in6->s6_addr[8], addr, 8); else if (addrlen == 6) { in6->s6_addr[8] = addr[0]; in6->s6_addr[9] = addr[1]; @@ -244,7 +244,7 @@ in6_get_soii_ifid(struct ifnet *ifp, struct in6_addr *in6) SHA512Update(&ctx, ip6_soiikey, sizeof(ip6_soiikey)); SHA512Final(digest, &ctx); - bcopy(digest + (sizeof(digest) - 8), &in6->s6_addr[8], 8); + memcpy(&in6->s6_addr[8], digest + (sizeof(digest) - 8), 8); return 0; } @@ -464,7 +464,7 @@ in6_nigroup(struct ifnet *ifp, const char *name, int namelen, sa6->sin6_addr.s6_addr16[0] = htons(0xff02); sa6->sin6_addr.s6_addr16[1] = htons(ifp->if_index); sa6->sin6_addr.s6_addr8[11] = 2; - bcopy(digest, &sa6->sin6_addr.s6_addr32[3], + memcpy(&sa6->sin6_addr.s6_addr32[3], digest, sizeof(sa6->sin6_addr.s6_addr32[3])); return 0; diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index fc115fb0d40..c84b5503851 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_output.c,v 1.236 2018/03/21 14:42:41 bluhm Exp $ */ +/* $OpenBSD: ip6_output.c,v 1.237 2018/03/27 15:03:52 dhill Exp $ */ /* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */ /* @@ -861,7 +861,7 @@ ip6_copyexthdr(struct mbuf **mp, caddr_t hdr, int hlen) } m->m_len = hlen; if (hdr) - bcopy(hdr, mtod(m, caddr_t), hlen); + memcpy(mtod(m, caddr_t), hdr, hlen); *mp = m; return (0); @@ -929,7 +929,7 @@ ip6_insert_jumboopt(struct ip6_exthdrs *exthdrs, u_int32_t plen) if (!n) return (ENOBUFS); n->m_len = oldoptlen + JUMBOOPTLEN; - bcopy(mtod(mopt, caddr_t), mtod(n, caddr_t), + memcpy(mtod(n, caddr_t), mtod(mopt, caddr_t), oldoptlen); optbuf = mtod(n, u_int8_t *) + oldoptlen; m_freem(mopt); |