Commit f0d1bf61 authored by Pavel Tikhomirov's avatar Pavel Tikhomirov Committed by Pavel Emelyanov

sysctl: append '\0' in sysctl_read_char

Before these patch one need to zero-init char buffer before giving
it to sysctl_op, it can be convenient to remove these restriction.
Signed-off-by: 's avatarPavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 24a528fd
...@@ -130,12 +130,13 @@ sysctl_read_char(int fd, struct sysctl_req *req, char *arg, int nr) ...@@ -130,12 +130,13 @@ sysctl_read_char(int fd, struct sysctl_req *req, char *arg, int nr)
int ret = -1; int ret = -1;
pr_debug("%s nr %d\n", req->name, nr); pr_debug("%s nr %d\n", req->name, nr);
ret = read(fd, arg, nr); ret = read(fd, arg, nr - 1);
if (ret < 0) { if (ret < 0) {
if (errno != EIO || !(req->flags & CTL_FLAGS_READ_EIO_SKIP)) if (errno != EIO || !(req->flags & CTL_FLAGS_READ_EIO_SKIP))
pr_perror("Can't read %s", req->name); pr_perror("Can't read %s", req->name);
goto err; goto err;
} }
arg[ret]='\0';
ret = 0; ret = 0;
err: err:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment