Commit 750324af authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

mount: Cleanup readlinkat calling

 - Use sizeof instead of PATH_MAX constant
 - Place EOS exactly after read data end
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Acked-by: 's avatarAndrew Vagin <avagin@parallels.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent f345fc8f
......@@ -555,11 +555,11 @@ int mntns_collect_root(pid_t pid)
* and a root of mntns is the same. */
pfd = open_pid_proc(pid);
ret = readlinkat(pfd, "root", path, PATH_MAX);
ret = readlinkat(pfd, "root", path, sizeof(path) - 1);
if (ret < 0)
return ret;
path[ret + 1] = '\0';
path[ret] = '\0';
if (ret != 1 || path[0] != '/') {
pr_err("The root task has another root than mntns: %s\n", path);
......
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