Development discussion of WireGuard
 help / color / mirror / Atom feed
* [PATCH] uapi: always print valid errors
@ 2017-01-08 20:40 James Tucker
  2017-01-08 22:01 ` Jason A. Donenfeld
  0 siblings, 1 reply; 2+ messages in thread
From: James Tucker @ 2017-01-08 20:40 UTC (permalink / raw)
  To: wireguard

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@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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] uapi: always print valid errors
  2017-01-08 20:40 [PATCH] uapi: always print valid errors James Tucker
@ 2017-01-08 22:01 ` Jason A. Donenfeld
  0 siblings, 0 replies; 2+ messages in thread
From: Jason A. Donenfeld @ 2017-01-08 22:01 UTC (permalink / raw)
  To: James Tucker; +Cc: WireGuard mailing list

Approached a bit differently, but thanks for catching this:
https://git.zx2c4.com/WireGuard/commit/?id=662235ea4d466584a13ee2edb91eb12a5f553ba6

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-08 21:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-08 20:40 [PATCH] uapi: always print valid errors James Tucker
2017-01-08 22:01 ` Jason A. Donenfeld

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).