]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
confile: don't leak memory when overwriting lxc.rootfs.options
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 26 Mar 2021 15:02:04 +0000 (16:02 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 29 Mar 2021 15:00:38 +0000 (17:00 +0200)
Link: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32473
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/confile.c

index 6fbcf6f9df083568d48547449d058d56d4ee9629..bddbdaea789f7e94315de782ee97f405ca657139 100644 (file)
@@ -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;
 }