Hello -

Here is a diff to switch some bcopy's to memcpy's.

Most bcopy's are on freshly alloc'd memory.

Index: ip6_output.c
===================================================================
RCS file: /cvs/src/sys/netinet6/ip6_output.c,v
retrieving revision 1.213
diff -u -p -r1.213 ip6_output.c
--- ip6_output.c        25 Aug 2016 12:30:16 -0000      1.213
+++ ip6_output.c        7 Sep 2016 21:10:41 -0000
@@ -969,7 +969,7 @@ ip6_insert_jumboopt(struct ip6_exthdrs *
        optbuf[2] = IP6OPT_JUMBO;
        optbuf[3] = 4;
        v = (u_int32_t)htonl(plen + JUMBOOPTLEN);
-       bcopy(&v, &optbuf[4], sizeof(u_int32_t));
+       memcpy(&optbuf[4], &v, sizeof(u_int32_t));
 
        /* finally, adjust the packet header length */
        exthdrs->ip6e_ip6->m_pkthdr.len += JUMBOOPTLEN;
@@ -1906,11 +1906,11 @@ ip6_clearpktopts(struct ip6_pktopts *pkt
 #define PKTOPT_EXTHDRCPY(type) \
 do {\
        if (src->type) {\
-               int hlen = (((struct ip6_ext *)src->type)->ip6e_len + 1) << 3;\
+               size_t hlen = (((struct ip6_ext *)src->type)->ip6e_len + 1) << 
3;\
                dst->type = malloc(hlen, M_IP6OPT, canwait);\
                if (dst->type == NULL && canwait == M_NOWAIT)\
                        goto bad;\
-               bcopy(src->type, dst->type, hlen);\
+               memcpy(dst->type, src->type, hlen);\
        }\
 } while (/*CONSTCOND*/ 0)
 
@@ -1993,7 +1993,7 @@ ip6_setmoptions(int optname, struct ip6_
                        error = EINVAL;
                        break;
                }
-               bcopy(mtod(m, u_int *), &ifindex, sizeof(ifindex));
+               memcpy(&ifindex, mtod(m, u_int *), sizeof(ifindex));
                if (ifindex != 0) {
                        ifp = if_get(ifindex);
                        if (ifp == NULL) {
@@ -2020,7 +2020,7 @@ ip6_setmoptions(int optname, struct ip6_
                        error = EINVAL;
                        break;
                }
-               bcopy(mtod(m, u_int *), &optval, sizeof(optval));
+               memcpy(&optval, mtod(m, u_int *), sizeof(optval));
                if (optval < -1 || optval >= 256)
                        error = EINVAL;
                else if (optval == -1)
@@ -2039,7 +2039,7 @@ ip6_setmoptions(int optname, struct ip6_
                        error = EINVAL;
                        break;
                }
-               bcopy(mtod(m, u_int *), &loop, sizeof(loop));
+               memcpy(&loop, mtod(m, u_int *), sizeof(loop));
                if (loop > 1) {
                        error = EINVAL;
                        break;
@@ -2522,7 +2522,7 @@ ip6_setpktopt(int optname, u_char *buf, 
                opt->ip6po_hbh = malloc(hbhlen, M_IP6OPT, M_NOWAIT);
                if (opt->ip6po_hbh == NULL)
                        return (ENOBUFS);
-               bcopy(hbh, opt->ip6po_hbh, hbhlen);
+               memcpy(opt->ip6po_hbh, hbh, hbhlen);
 
                break;
        }
@@ -2566,7 +2566,7 @@ ip6_setpktopt(int optname, u_char *buf, 
                *newdest = malloc(destlen, M_IP6OPT, M_NOWAIT);
                if (*newdest == NULL)
                        return (ENOBUFS);
-               bcopy(dest, *newdest, destlen);
+               memcpy(*newdest, dest, destlen);
 
                break;
        }
@@ -2606,7 +2606,7 @@ ip6_setpktopt(int optname, u_char *buf, 
                opt->ip6po_rthdr = malloc(rthlen, M_IP6OPT, M_NOWAIT);
                if (opt->ip6po_rthdr == NULL)
                        return (ENOBUFS);
-               bcopy(rth, opt->ip6po_rthdr, rthlen);
+               memcpy(opt->ip6po_rthdr, rth, rthlen);
                break;
        }
 
Index: raw_ip6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/raw_ip6.c,v
retrieving revision 1.95
diff -u -p -r1.95 raw_ip6.c
--- raw_ip6.c   22 Aug 2016 10:33:22 -0000      1.95
+++ raw_ip6.c   7 Sep 2016 21:10:41 -0000
@@ -735,7 +735,7 @@ rip6_usrreq(struct socket *so, int req, 
                        bzero(&tmp, sizeof(tmp));
                        tmp.sin6_family = AF_INET6;
                        tmp.sin6_len = sizeof(struct sockaddr_in6);
-                       bcopy(&in6p->inp_faddr6, &tmp.sin6_addr,
+                       memcpy(&tmp.sin6_addr, &in6p->inp_faddr6,
                            sizeof(struct in6_addr));
                        dst = &tmp;
                } else {

Reply via email to