]> git.ipfire.org Git - thirdparty/wireguard-tools.git/commitdiff
wg: stricter userspace ipc parsing
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 2 Aug 2017 19:07:25 +0000 (21:07 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Wed, 2 Aug 2017 19:09:22 +0000 (21:09 +0200)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
src/ipc.c

index ed5fbc280b1057349010453c3da70a45ab01dbba..48d06aaee14f13b14d33335a6f9fa31f153087a6 100644 (file)
--- 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));