aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-01-25 21:22:36 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2021-01-25 21:22:36 +0100
commit457f96b65e4f7241aceaa7cb9c7bbce7be1a2212 (patch)
treefd31c75511840023621f7324676a911d4f652a62 /src
parentsticky-sockets: do not use SO_REUSEADDR (diff)
downloadwireguard-tools-457f96b65e4f7241aceaa7cb9c7bbce7be1a2212.tar.xz
wireguard-tools-457f96b65e4f7241aceaa7cb9c7bbce7be1a2212.zip
ipc: do not use fscanf with trailing \n
If the stream is not closed, then this winds up hanging forever. So remove the trailing \n\n and check manually after. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src')
-rw-r--r--src/ipc-uapi.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ipc-uapi.h b/src/ipc-uapi.h
index f464be7..d2ba522 100644
--- a/src/ipc-uapi.h
+++ b/src/ipc-uapi.h
@@ -92,8 +92,10 @@ static int userspace_set_device(struct wgdevice *dev)
fprintf(f, "\n");
fflush(f);
- if (fscanf(f, "errno=%d\n\n", &ret) != 1)
+ if (fscanf(f, "errno=%d", &ret) != 1)
ret = errno ? -errno : -EPROTO;
+ if (getc(f) != '\n' || getc(f) != '\n')
+ ret = -EPROTO;
fclose(f);
errno = -ret;
return ret;