From: James Tucker <jftucker@gmail.com>
To: wireguard@lists.zx2c4.com
Subject: [PATCH] uapi: always print valid errors
Date: Sun, 8 Jan 2017 12:40:26 -0800 [thread overview]
Message-ID: <20170108204026.29033-1-jftucker@gmail.com> (raw)
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
next reply other threads:[~2017-01-08 20:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-08 20:40 James Tucker [this message]
2017-01-08 22:01 ` Jason A. Donenfeld
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170108204026.29033-1-jftucker@gmail.com \
--to=jftucker@gmail.com \
--cc=wireguard@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).