From bc9494f8b68fc138ba6bc303ca90cee1b33e3ea9 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 2 Aug 2017 21:07:25 +0200 Subject: [PATCH] wg: stricter userspace ipc parsing Signed-off-by: Jason A. Donenfeld --- src/ipc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ipc.c b/src/ipc.c index ed5fbc2..48d06aa 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -314,13 +314,13 @@ static int userspace_get_device(struct wgdevice **out, const char *interface) break; *value++ = key[--line_len] = '\0'; - if (!strcmp(key, "private_key")) { + if (!peer && !strcmp(key, "private_key")) { if (!key_from_hex(dev->private_key, value)) break; curve25519_generate_public(dev->public_key, dev->private_key); - } else if (!strcmp(key, "listen_port")) + } else if (!peer && !strcmp(key, "listen_port")) dev->port = NUM(0xffffU); - else if (!strcmp(key, "fwmark")) + else if (!peer && !strcmp(key, "fwmark")) dev->fwmark = NUM(0xffffffffU); else if (!strcmp(key, "public_key")) { peer = ADD(sizeof(struct wgpeer));