From 2e5c468aa59b6458d2894e7b5c730ca251e84b57 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Thu, 22 Apr 2021 21:09:12 +0200 Subject: [PATCH] conf: don't overrun dest buffer in parse_lxc_mntopts() Signed-off-by: Christian Brauner --- src/lxc/conf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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"); -- 2.47.2