From: Christian Brauner Date: Thu, 22 Apr 2021 19:09:12 +0000 (+0200) Subject: conf: don't overrun dest buffer in parse_lxc_mntopts() X-Git-Tag: lxc-5.0.0~194^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F3805%2Fhead;p=thirdparty%2Flxc.git conf: don't overrun dest buffer in parse_lxc_mntopts() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/conf.c b/src/lxc/conf.c index 0f323091b..3ca5cf447 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -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=\" 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=\" LXC specific mount option");