]> git.proxmox.com Git - mirror_lxc.git/commitdiff
conf: don't overrun dest buffer in parse_lxc_mntopts()
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 22 Apr 2021 19:09:12 +0000 (21:09 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 22 Apr 2021 19:09:12 +0000 (21:09 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c

index 0f323091b1ba5570cee4ffdad653e2e54e0bb47a..3ca5cf44755f07d12073ec2884f1ead080399a2a 100644 (file)
@@ -2154,11 +2154,13 @@ int parse_lxc_mntopts(struct lxc_mount_options *opts, char *mnt_opts)
                        opt_next = opt;
                        opt_next += STRLITERALLEN("idmap=");
                        idmap_path = strchrnul(opt_next, ',');
+                       len = idmap_path - opt_next + 1;
 
-                       len = strlcpy(opts->userns_path, opt_next, idmap_path - opt_next + 1);
                        if (len >= sizeof(opts->userns_path))
                                return syserror_set(-EIO, "Excessive idmap path length for \"idmap=<path>\" LXC specific mount option");
 
+                       memcpy(opts->userns_path, opt_next, len);
+
                        if (is_empty_string(opts->userns_path))
                                return syserror_set(-EINVAL, "Missing idmap path for \"idmap=<path>\" LXC specific mount option");