diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-09-26 15:02:41 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-09-26 15:04:07 +0200 |
commit | 9a0790b50a54ae85f741ec129591bbfd8934525b (patch) | |
tree | e919cd5913e2b12ac972dcff5d3e09d662a3e7ae /src/ipc.c | |
parent | wg: use key_is_zero for comparing to zeros (diff) | |
download | wireguard-tools-9a0790b50a54ae85f741ec129591bbfd8934525b.tar.xz wireguard-tools-9a0790b50a54ae85f741ec129591bbfd8934525b.zip |
wg: uapi: only make sure socket file is socket
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | src/ipc.c | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -129,11 +129,16 @@ out: static bool userspace_has_wireguard_interface(const char *interface) { - FILE *f = userspace_interface_file(interface); - if (!f) + struct stat sbuf; + char path[PATH_MAX] = { 0 }; + + if (strchr(interface, '/')) return false; - fclose(f); - return true; + if (snprintf(path, sizeof(path) - 1, SOCK_PATH "%s" SOCK_SUFFIX, interface) < 0) + return false; + if (stat(path, &sbuf) < 0) + return false; + return S_ISSOCK(sbuf.st_mode); } static int userspace_get_wireguard_interfaces(struct inflatable_buffer *buffer) |