Skip to content

Commit

Permalink
sysctl: append '\0' in sysctl_read_char
Browse files Browse the repository at this point in the history
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: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
  • Loading branch information
Snorch authored and xemul committed Jul 15, 2016
1 parent f56568e commit dc72792
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion criu/sysctl.c
Expand Up @@ -130,12 +130,13 @@ sysctl_read_char(int fd, struct sysctl_req *req, char *arg, int nr)
int ret = -1;

pr_debug("%s nr %d\n", req->name, nr);
ret = read(fd, arg, nr);
ret = read(fd, arg, nr - 1);
if (ret < 0) {
if (errno != EIO || !(req->flags & CTL_FLAGS_READ_EIO_SKIP))
pr_perror("Can't read %s", req->name);
goto err;
}
arg[ret]='\0';
ret = 0;

err:
Expand Down

0 comments on commit dc72792

Please sign in to comment.