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

View file

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