[PATCH] uapi: always print valid errors
James Tucker
jftucker at gmail.com
Sun Jan 8 21:40:26 CET 2017
ret_code is now initialized for the case of short reads.
The 0 length reads/eof case is now treated appropriately.
Signed-off-by: James Tucker <jftucker at gmail.com>
---
src/tools/ipc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/tools/ipc.c b/src/tools/ipc.c
index c8ca431..cc512f3 100644
--- a/src/tools/ipc.c
+++ b/src/tools/ipc.c
@@ -164,7 +164,7 @@ static int userspace_set_device(struct wgdevice *dev)
struct wgpeer *peer;
size_t len;
ssize_t ret;
- int ret_code;
+ int ret_code = 0;
int fd = userspace_interface_fd(dev->interface);
if (fd < 0)
return fd;
@@ -177,8 +177,10 @@ static int userspace_set_device(struct wgdevice *dev)
if (ret < 0)
goto out;
ret = read(fd, &ret_code, sizeof(ret_code));
- if (ret < 0)
+ if (ret <= 0) {
+ ret = -errno;
goto out;
+ }
ret = ret_code;
out:
close(fd);
--
2.11.0
More information about the WireGuard
mailing list