diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-05-02 19:50:05 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-05-02 19:51:21 +0200 |
commit | 9095d0340963aa35f1455e43f758c905d5832e3a (patch) | |
tree | 3bdb94ca54e3fed38e5d2a37d4adc0d2810c52c8 /src | |
parent | if_wg: pad packets properly (diff) | |
download | wireguard-freebsd-9095d0340963aa35f1455e43f758c905d5832e3a.tar.xz wireguard-freebsd-9095d0340963aa35f1455e43f758c905d5832e3a.zip |
if_wg: don't memcpy data for no reason
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/if_wg.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/if_wg.c b/src/if_wg.c index 1a039a0..a373958 100644 --- a/src/if_wg.c +++ b/src/if_wg.c @@ -1548,7 +1548,6 @@ out: static void wg_decrypt(struct wg_softc *sc, struct wg_packet *pkt) { - struct wg_pkt_data data; struct wg_peer *peer, *allowed_peer; struct noise_remote *remote; struct mbuf *m; @@ -1559,11 +1558,10 @@ wg_decrypt(struct wg_softc *sc, struct wg_packet *pkt) peer = noise_remote_arg(remote); m = pkt->p_mbuf; - /* Read index, nonce and then adjust to remove the header. */ - memcpy(&data, mtod(m, void *), sizeof(struct wg_pkt_data)); + /* Read nonce and then adjust to remove the header. */ + pkt->p_nonce = le64toh(mtod(m, struct wg_pkt_data *)->nonce); m_adj(m, sizeof(struct wg_pkt_data)); - pkt->p_nonce = le64toh(data.nonce); if (noise_keypair_decrypt(pkt->p_keypair, pkt->p_nonce, m) != 0) goto out; |