wg: error on short ret reads

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2017-01-08 23:00:41 +01:00
parent 16060516bb
commit e92e0dca14
1 changed files with 4 additions and 0 deletions

View File

@ -179,6 +179,10 @@ static int userspace_set_device(struct wgdevice *dev)
ret = read(fd, &ret_code, sizeof(ret_code));
if (ret < 0)
goto out;
if (ret != sizeof(ret_code)) {
ret = -EBADMSG;
goto out;
}
ret = ret_code;
out:
close(fd);