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-5.0.0~242^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c04f422182501585e2e92a238dc416ce21ff077d;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 6220f4702..518812804 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -2667,6 +2667,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); @@ -2679,9 +2683,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; }