]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
utils: use lxc_safe_int()
authorChristian Brauner <christian.brauner@canonical.com>
Sat, 29 Oct 2016 10:00:06 +0000 (12:00 +0200)
committerChristian Brauner <christian.brauner@canonical.com>
Tue, 22 Nov 2016 03:46:00 +0000 (04:46 +0100)
Signed-off-by: Christian Brauner <christian.brauner@canonical.com>
src/lxc/utils.c

index 3b05842b6baf915e3b12adfe54574e9fc1f86edc..e1191a3cff51f4c446f82563ddd732f3a181bfc0 100644 (file)
@@ -1766,7 +1766,7 @@ int mount_proc_if_needed(const char *rootfs)
 {
        char path[MAXPATHLEN];
        char link[20];
-       int linklen, ret;
+       int link_to_pid, linklen, ret;
        int mypid;
 
        ret = snprintf(path, MAXPATHLEN, "%s/proc/self", rootfs);
@@ -1785,7 +1785,9 @@ int mount_proc_if_needed(const char *rootfs)
        }
        if (linklen < 0) /* /proc not mounted */
                goto domount;
-       if (atoi(link) != mypid) {
+       if (lxc_safe_int(link, &link_to_pid) < 0)
+               return -1;
+       if (link_to_pid != mypid) {
                /* wrong /procs mounted */
                umount2(path, MNT_DETACH); /* ignore failure */
                goto domount;