Project

General

Profile

Bug #11338 » PR11338_wg_tools.diff

Peter Grehan, 01/31/2021 01:00 AM

View differences:

src/ipc-freebsd.h
132 132
		nvlist_add_binary(nvl_peer, "pre-shared-key", peer->preshared_key, WG_KEY_LEN); /* TODO: preshared-key instead of pre-shared-key */
133 133
	if (peer->flags & WGPEER_HAS_PERSISTENT_KEEPALIVE_INTERVAL)
134 134
		nvlist_add_number(nvl_peer, "persistent-keepalive-interval", peer->persistent_keepalive_interval);
135
	if ((peer->endpoint.addr.sa_family == AF_INET || peer->endpoint.addr.sa_family == AF_INET6) &&
136
	    peer->endpoint.addr.sa_len <= sizeof(struct sockaddr))
137
		nvlist_add_binary(nvl_peer, "endpoint", &peer->endpoint.addr, sizeof(struct sockaddr));
135
	if (peer->endpoint.addr.sa_family == AF_INET || peer->endpoint.addr.sa_family == AF_INET6)
136
		nvlist_add_binary(nvl_peer, "endpoint", &peer->endpoint.addr, peer->endpoint.addr.sa_len);
138 137
	nvlist_add_bool(nvl_peer, "replace-allowedips", !!(peer->flags & WGPEER_REPLACE_ALLOWEDIPS));
139 138
	nvlist_add_bool(nvl_peer, "peer-remove", !!(peer->flags & WGPEER_REMOVE_ME));
140 139
	for_each_wgallowedip(peer, aip) {
......
188 187
	}
189 188
	if (nvlist_exists_binary(nvl_peer, "endpoint")) {
190 189
		endpoint = nvlist_get_binary(nvl_peer, "endpoint", &size);
191
		if (size <= sizeof(peer->endpoint.addr))
192
			memcpy(&peer->endpoint.addr, endpoint, endpoint->sa_len);
190
		if (size <= sizeof(peer->endpoint))
191
			memcpy(&peer->endpoint.addr, endpoint, size);
193 192
	}
194 193
	if (nvlist_exists_number(nvl_peer, "rx_bytes"))
195 194
		peer->rx_bytes = nvlist_get_number(nvl_peer, "rx_bytes");
(1-1/2)