[CRIU] [PATCH 1/5] sysctl: append '\0' in sysctl_read_char
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Thu Jul 14 06:51:10 PDT 2016
Before these patch one need to zero-init char buffer before giving
it to sysctl_op, it can be convenient to remove these restriction.
https://jira.sw.ru/browse/PSBM-48397
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
criu/sysctl.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/criu/sysctl.c b/criu/sysctl.c
index 77d9bda..87bd267 100644
--- a/criu/sysctl.c
+++ b/criu/sysctl.c
@@ -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:
--
2.5.5
More information about the CRIU
mailing list