Page MenuHomeFreeBSD

D28933.diff
No OneTemporary

D28933.diff

diff --git a/sys/dev/if_wg/module/if_wg_session.c b/sys/dev/if_wg/module/if_wg_session.c
--- a/sys/dev/if_wg/module/if_wg_session.c
+++ b/sys/dev/if_wg/module/if_wg_session.c
@@ -1882,7 +1882,16 @@
goto free;
}
e = wg_mbuf_endpoint_get(m);
- e->e_remote.r_sa = *srcsa;
+ switch (srcsa->sa_family) {
+ case AF_INET:
+ memcpy(&e->e_remote.r_sa, srcsa, sizeof(struct sockaddr_in));
+ break;
+ case AF_INET6:
+ memcpy(&e->e_remote.r_sa, srcsa, sizeof(struct sockaddr_in6));
+ break;
+ default:
+ memcpy(&e->e_remote.r_sa, srcsa, sizeof(struct sockaddr));
+ }
verify_endpoint(m);
if_inc_counter(sc->sc_ifp, IFCOUNTER_IPACKETS, 1);
diff --git a/sys/dev/if_wg/module/module.c b/sys/dev/if_wg/module/module.c
--- a/sys/dev/if_wg/module/module.c
+++ b/sys/dev/if_wg/module/module.c
@@ -392,7 +392,8 @@
return (NULL);
key = peer->p_remote.r_public;
nvlist_add_binary(nvl, "public-key", key, WG_KEY_SIZE);
- nvlist_add_binary(nvl, "endpoint", &peer->p_endpoint.e_remote, sizeof(struct sockaddr));
+ nvlist_add_binary(nvl, "endpoint", &peer->p_endpoint.e_remote,
+ peer->p_endpoint.e_remote.r_sa.sa_len);
i = count = 0;
CK_LIST_FOREACH(rt, &peer->p_routes, r_entry) {
count++;
@@ -587,13 +588,12 @@
}
if (nvlist_exists_binary(nvl, "endpoint")) {
endpoint = nvlist_get_binary(nvl, "endpoint", &size);
- if (size != sizeof(*endpoint)) {
+ if (size > sizeof(peer->p_endpoint.e_remote)) {
device_printf(dev, "%s bad length for endpoint %zu\n", __func__, size);
err = EBADMSG;
goto out;
}
- memcpy(&peer->p_endpoint.e_remote, endpoint,
- sizeof(peer->p_endpoint.e_remote));
+ memcpy(&peer->p_endpoint.e_remote, endpoint, size);
}
if (nvlist_exists_binary(nvl, "pre-shared-key")) {
const void *key;

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 29, 6:44 AM (8 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15628396
Default Alt Text
D28933.diff (1 KB)

Event Timeline