[CRIU] [PATCH 1/2] mount: Cleanup readlinkat calling
Cyrill Gorcunov
gorcunov at openvz.org
Thu Aug 2 03:24:59 EDT 2012
- Use sizeof instead of PATH_MAX constant
- Place EOS exactly after read data end
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
mount.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mount.c b/mount.c
index be907a9..295808a 100644
--- a/mount.c
+++ b/mount.c
@@ -511,11 +511,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);
--
1.7.7.6
More information about the CRIU
mailing list