From: Christian Brauner Date: Fri, 26 Mar 2021 15:02:04 +0000 (+0100) Subject: confile: don't leak memory when overwriting lxc.rootfs.options X-Git-Tag: lxc-4.0.7~150 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e6d15fca7b3c227fbeefda9b67f2c6672d1b4c1b;p=thirdparty%2Flxc.git confile: don't leak memory when overwriting lxc.rootfs.options Link: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32473 Signed-off-by: Christian Brauner --- diff --git a/src/lxc/confile.c b/src/lxc/confile.c index 6fbcf6f9d..bddbdaea7 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -2465,6 +2465,10 @@ static int set_config_rootfs_options(const char *key, const char *value, struct lxc_rootfs *rootfs = &lxc_conf->rootfs; int ret; + clr_config_rootfs_options(key, lxc_conf, data); + if (lxc_config_value_empty(value)) + return 0; + ret = parse_mntopts(value, &mflags, &mdata); if (ret < 0) return ret_errno(EINVAL); @@ -2477,9 +2481,9 @@ static int set_config_rootfs_options(const char *key, const char *value, if (ret < 0) return ret_errno(ENOMEM); - rootfs->mountflags = mflags | pflags; - rootfs->options = move_ptr(opts); - rootfs->data = move_ptr(mdata); + rootfs->mountflags = mflags | pflags; + rootfs->options = move_ptr(opts); + rootfs->data = move_ptr(mdata); return 0; }