summaryrefslogtreecommitdiff
path: root/proto/wireguard/wireguard.c
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2019-09-27 22:20:59 +0200
committerMikael Magnusson <mikma@users.sourceforge.net>2019-11-15 00:11:29 +0100
commitc714681773bb0b932d55b2028c46e3a7982bdd6a (patch)
treea122415b9b04d64dc8d7d6858499752180f2dd38 /proto/wireguard/wireguard.c
parent5e0835d9a7b5259d9e9887c1f9faedd09e1c8397 (diff)
Wireguard: Generalize tunnel encapsulation
Diffstat (limited to 'proto/wireguard/wireguard.c')
-rw-r--r--proto/wireguard/wireguard.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/proto/wireguard/wireguard.c b/proto/wireguard/wireguard.c
index 6733010d..2c2e6796 100644
--- a/proto/wireguard/wireguard.c
+++ b/proto/wireguard/wireguard.c
@@ -16,8 +16,6 @@
#include "sysdep/unix/wg_user.h"
#include "wireguard.h"
-#define BA_TUNNEL_ENCAP 0x17
-
static
int get_device(struct wg_proto *p, wg_device **pdev, const char *device_name)
{
@@ -257,7 +255,8 @@ wg_rt_notify(struct proto *P, struct channel *CH, struct network *n,
new->attrs->dest, n->n.addr);
wg_key pubkey;
- memset(pubkey, 0, sizeof(wg_key));
+ size_t pubkey_size = sizeof(wg_key);
+ memset(pubkey, 0, pubkey_size);
u32 tunnel_ep_as4 = 0;
ip_addr tunnel_ep_addr = IPA_NONE;
u16 udp_dest_port = 0;
@@ -268,7 +267,7 @@ wg_rt_notify(struct proto *P, struct channel *CH, struct network *n,
if (!t && he && he->src) {
t = ea_find(he->src->eattrs, EA_CODE(PROTOCOL_BGP, BA_TUNNEL_ENCAP));
}
- if (t && t->u.ptr && decode_tunnel_encap(t, c->tunnel_type, &pubkey, &tunnel_ep_as4, &tunnel_ep_addr, &color, &udp_dest_port, &flags) == 0) {
+ if (t && t->u.ptr && decode_tunnel_encap(t, c->tunnel_type, &pubkey, &pubkey_size, &tunnel_ep_as4, &tunnel_ep_addr, &color, &udp_dest_port, &flags) == 0 && pubkey_size == sizeof(wg_key)) {
log(L_TRACE "WG: Attr %x %x %d %04x", t->flags, t->type, t->u.ptr->length, flags);
struct wg_device *dev = p->dev;