Commit 250c89ed authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Pavel Emelyanov

read_ns_sys_file(): check if buf is long enough

In case buf size is not adequate, report and return an error.
This is modelled after commit 1ead3d79.
Signed-off-by: 's avatarKir Kolyshkin <kir@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ec863205
......@@ -45,6 +45,11 @@ int read_ns_sys_file(char *path, char *buf, int len)
rlen = read(fd, buf, len);
close(fd);
if (rlen == len) {
pr_err("Too small buffer to read ns sys file %s\n", path);
return -1;
}
if (rlen > 0)
buf[rlen - 1] = '\0';
......
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