summaryrefslogtreecommitdiff
path: root/proto/wireguard/wireguard.c
diff options
context:
space:
mode:
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 212fc779..a355bf43 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;