[CRIU] [PATCH 1/2] mount: Cleanup readlinkat calling
Andrew Vagin
avagin at parallels.com
Thu Aug 2 05:43:52 EDT 2012
On Thu, Aug 02, 2012 at 11:24:59AM +0400, Cyrill Gorcunov wrote:
> - Use sizeof instead of PATH_MAX constant
> - Place EOS exactly after read data end
>
Acked-by: Andrew Vagin <avagin at parallels.com>
> 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
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://openvz.org/mailman/listinfo/criu
More information about the CRIU
mailing list