On Fri, Mar 24, 2017 at 12:58:29PM -0400, David Hill wrote:
> This diff converts the existing three bcopy's to memcpy or memmove.
> The memcpy's are on freshly malloc'd memory so no overlap.

As tc and tdb are properly aligned malloc(9)ed data and tc_dst and
tdb_dst are sockaddr_union fields contained in this storage, I think
we can just say "tc->tc_dst = tdb->tdb_dst" and the compiler knows
what to do.

> OK?

OK bluhm@ for memmove(9)ing the mbuf data.

> Index: netinet/ip_ipcomp.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/ip_ipcomp.c,v
> retrieving revision 1.55
> diff -u -p -r1.55 ip_ipcomp.c
> --- netinet/ip_ipcomp.c       17 Feb 2017 14:49:03 -0000      1.55
> +++ netinet/ip_ipcomp.c       24 Mar 2017 16:54:37 -0000
> @@ -181,7 +181,7 @@ ipcomp_input(struct mbuf *m, struct tdb 
>       tc->tc_spi = tdb->tdb_spi;
>       tc->tc_proto = IPPROTO_IPCOMP;
>       tc->tc_rdomain = tdb->tdb_rdomain;
> -     bcopy(&tdb->tdb_dst, &tc->tc_dst, sizeof(union sockaddr_union));
> +     memcpy(&tc->tc_dst, &tdb->tdb_dst, sizeof(union sockaddr_union));
>  
>       return crypto_dispatch(crp);
>  }
> @@ -317,8 +317,8 @@ ipcomp_input_cb(struct cryptop *crp)
>               /* Finally, let's relink */
>               m1->m_next = mo;
>       } else {
> -             bcopy(mtod(m1, u_char *) + roff + hlen,
> -                 mtod(m1, u_char *) + roff,
> +             memmove(mtod(m1, u_char *) + roff,
> +                 mtod(m1, u_char *) + roff + hlen,
>                   m1->m_len - (roff + hlen));
>               m1->m_len -= hlen;
>               m->m_pkthdr.len -= hlen;
> @@ -501,7 +501,7 @@ ipcomp_output(struct mbuf *m, struct tdb
>       tc->tc_proto = tdb->tdb_sproto;
>       tc->tc_skip = skip;
>       tc->tc_rdomain = tdb->tdb_rdomain;
> -     bcopy(&tdb->tdb_dst, &tc->tc_dst, sizeof(union sockaddr_union));
> +     memcpy(&tc->tc_dst, &tdb->tdb_dst, sizeof(union sockaddr_union));
>  
>       /* Crypto operation descriptor */
>       crp->crp_ilen = m->m_pkthdr.len;        /* Total input length */

Reply via email to