netinet6 - bcopy -> memcpy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

netinet6 - bcopy -> memcpy

David Hill-3
Hello -

A few bcopy to memcpy conversions where the memory does not overlap.

OK?

Index: netinet6/icmp6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/icmp6.c,v
retrieving revision 1.221
diff -u -p -r1.221 icmp6.c
--- netinet6/icmp6.c 14 Dec 2017 14:26:50 -0000 1.221
+++ netinet6/icmp6.c 13 Mar 2018 21:32:32 -0000
@@ -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), (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
  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
  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
  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));
  }
 
Index: netinet6/in6_ifattach.c
===================================================================
RCS file: /cvs/src/sys/netinet6/in6_ifattach.c,v
retrieving revision 1.106
diff -u -p -r1.106 in6_ifattach.c
--- netinet6/in6_ifattach.c 13 Mar 2018 13:58:03 -0000 1.106
+++ netinet6/in6_ifattach.c 13 Mar 2018 21:32:33 -0000
@@ -165,7 +165,7 @@ in6_get_hw_ifid(struct ifnet *ifp, struc
 
  /* 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, str
  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 cha
  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;
Index: netinet6/ip6_output.c
===================================================================
RCS file: /cvs/src/sys/netinet6/ip6_output.c,v
retrieving revision 1.234
diff -u -p -r1.234 ip6_output.c
--- netinet6/ip6_output.c 19 Feb 2018 08:59:53 -0000 1.234
+++ netinet6/ip6_output.c 13 Mar 2018 21:32:33 -0000
@@ -850,7 +850,7 @@ ip6_copyexthdr(struct mbuf **mp, caddr_t
  }
  m->m_len = hlen;
  if (hdr)
- bcopy(hdr, mtod(m, caddr_t), hlen);
+ memcpy(mtod(m, caddr_t), hdr, hlen);
 
  *mp = m;
  return (0);
@@ -918,7 +918,7 @@ ip6_insert_jumboopt(struct ip6_exthdrs *
  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);

Reply | Threaded
Open this post in threaded view
|

Re: netinet6 - bcopy -> memcpy

Florian Obser-2
OK florian@ for after unlock

On Tue, Mar 13, 2018 at 05:40:24PM -0400, David Hill wrote:

> Hello -
>
> A few bcopy to memcpy conversions where the memory does not overlap.
>
> OK?
>
> Index: netinet6/icmp6.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/icmp6.c,v
> retrieving revision 1.221
> diff -u -p -r1.221 icmp6.c
> --- netinet6/icmp6.c 14 Dec 2017 14:26:50 -0000 1.221
> +++ netinet6/icmp6.c 13 Mar 2018 21:32:32 -0000
> @@ -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), (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
>   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
>   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
>   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));
>   }
>  
> Index: netinet6/in6_ifattach.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/in6_ifattach.c,v
> retrieving revision 1.106
> diff -u -p -r1.106 in6_ifattach.c
> --- netinet6/in6_ifattach.c 13 Mar 2018 13:58:03 -0000 1.106
> +++ netinet6/in6_ifattach.c 13 Mar 2018 21:32:33 -0000
> @@ -165,7 +165,7 @@ in6_get_hw_ifid(struct ifnet *ifp, struc
>  
>   /* 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, str
>   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 cha
>   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;
> Index: netinet6/ip6_output.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/ip6_output.c,v
> retrieving revision 1.234
> diff -u -p -r1.234 ip6_output.c
> --- netinet6/ip6_output.c 19 Feb 2018 08:59:53 -0000 1.234
> +++ netinet6/ip6_output.c 13 Mar 2018 21:32:33 -0000
> @@ -850,7 +850,7 @@ ip6_copyexthdr(struct mbuf **mp, caddr_t
>   }
>   m->m_len = hlen;
>   if (hdr)
> - bcopy(hdr, mtod(m, caddr_t), hlen);
> + memcpy(mtod(m, caddr_t), hdr, hlen);
>  
>   *mp = m;
>   return (0);
> @@ -918,7 +918,7 @@ ip6_insert_jumboopt(struct ip6_exthdrs *
>   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);
>

--
I'm not entirely sure you are real.