uapi: always print valid errors
PATCH 1/1 uapi: always print valid errors
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 <[email protected]>
--- src/tools/ipc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
src/tools/ipc.c +4 -2
@@ -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);
Signature · 1 line
2.11.0
Approached a bit differently, but thanks for catching this:
https://git.zx2c4.com/WireGuard/commit/?id=662235ea4d466584a13ee2edb91eb12a5f553ba6