summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Hill <dhill@cvs.openbsd.org>2017-04-06 17:36:19 +0000
committerDavid Hill <dhill@cvs.openbsd.org>2017-04-06 17:36:19 +0000
commit1ea85205533926f391fc2bc566af965c8f6267bf (patch)
tree4cc2ae87ead4faa378cfa8779f6074a2676aa5d8 /sys
parent689ca8feff4898459a85756d67d787be0e5a6e34 (diff)
Convert bcopy to memcpy where the memory does not overlap, otherwise,
use memmove. While here, change some previous conversions to a simple assignment. ok deraadt@
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/ip_esp.c13
-rw-r--r--sys/netinet/ip_mroute.c8
2 files changed, 11 insertions, 10 deletions
diff --git a/sys/netinet/ip_esp.c b/sys/netinet/ip_esp.c
index f2567a662a0..4d8f385dc55 100644
--- a/sys/netinet/ip_esp.c
+++ b/sys/netinet/ip_esp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_esp.c,v 1.146 2017/02/07 18:18:16 bluhm Exp $ */
+/* $OpenBSD: ip_esp.c,v 1.147 2017/04/06 17:36:18 dhill Exp $ */
/*
* The authors of this code are John Ioannidis (ji@tla.org),
* Angelos D. Keromytis (kermit@csd.uch.gr) and
@@ -504,7 +504,7 @@ esp_input(struct mbuf *m, struct tdb *tdb, int skip, int protoff)
tc->tc_spi = tdb->tdb_spi;
tc->tc_proto = tdb->tdb_sproto;
tc->tc_rdomain = tdb->tdb_rdomain;
- memcpy(&tc->tc_dst, &tdb->tdb_dst, sizeof(union sockaddr_union));
+ tc->tc_dst = tdb->tdb_dst;
/* Decryption descriptor */
if (espx) {
@@ -707,8 +707,9 @@ esp_input_cb(struct cryptop *crp)
* overlapping copy of the remainder of the mbuf over the ESP
* header.
*/
- bcopy(mtod(m1, u_char *) + roff + hlen,
- mtod(m1, u_char *) + roff, m1->m_len - (roff + hlen));
+ 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;
}
@@ -910,7 +911,7 @@ esp_output(struct mbuf *m, struct tdb *tdb, struct mbuf **mp, int skip,
}
/* Initialize ESP header. */
- bcopy((caddr_t) &tdb->tdb_spi, mtod(mo, caddr_t) + roff,
+ memcpy(mtod(mo, caddr_t) + roff, (caddr_t) &tdb->tdb_spi,
sizeof(u_int32_t));
tdb->tdb_rpl++;
replay = htonl((u_int32_t)tdb->tdb_rpl);
@@ -992,7 +993,7 @@ esp_output(struct mbuf *m, struct tdb *tdb, struct mbuf **mp, int skip,
tc->tc_spi = tdb->tdb_spi;
tc->tc_proto = tdb->tdb_sproto;
tc->tc_rdomain = tdb->tdb_rdomain;
- memcpy(&tc->tc_dst, &tdb->tdb_dst, sizeof(union sockaddr_union));
+ tc->tc_dst = tdb->tdb_dst;
/* Crypto operation descriptor. */
crp->crp_ilen = m->m_pkthdr.len; /* Total input length. */
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index 5236608831b..047adc9c3a9 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_mroute.c,v 1.112 2017/03/17 14:59:29 rzalamena Exp $ */
+/* $OpenBSD: ip_mroute.c,v 1.113 2017/04/06 17:36:18 dhill Exp $ */
/* $NetBSD: ip_mroute.c,v 1.85 2004/04/26 01:31:57 matt Exp $ */
/*
@@ -951,10 +951,10 @@ add_mfc(struct socket *so, struct mbuf *m)
*/
if (mrt_api_config & MRT_API_FLAGS_ALL) {
struct mfcctl2 *mp2 = mtod(m, struct mfcctl2 *);
- bcopy(mp2, (caddr_t)&mfcctl2, sizeof(*mp2));
+ memcpy((caddr_t)&mfcctl2, mp2, sizeof(*mp2));
} else {
struct mfcctl *mp = mtod(m, struct mfcctl *);
- bcopy(mp, (caddr_t)&mfcctl2, sizeof(*mp));
+ memcpy((caddr_t)&mfcctl2, mp, sizeof(*mp));
memset((caddr_t)&mfcctl2 + sizeof(struct mfcctl), 0,
sizeof(mfcctl2) - sizeof(struct mfcctl));
}
@@ -988,7 +988,7 @@ del_mfc(struct socket *so, struct mbuf *m)
mp = mtod(m, struct mfcctl *);
- bcopy(mp, (caddr_t)&mfcctl2, sizeof(*mp));
+ memcpy((caddr_t)&mfcctl2, mp, sizeof(*mp));
memset((caddr_t)&mfcctl2 + sizeof(struct mfcctl), 0,
sizeof(mfcctl2) - sizeof(struct mfcctl));