From c04f422182501585e2e92a238dc416ce21ff077d Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Fri, 26 Mar 2021 16:02:04 +0100 Subject: [PATCH] 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 --- src/lxc/confile.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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; } -- 2.47.2