]> 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>
Fri, 26 Mar 2021 15:02:04 +0000 (16:02 +0100)
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 6220f47025b7adc6b076ff3ed4a8b6c012162467..518812804ac296bc61ab6243708c829216d42b98 100644 (file)
@@ -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;
 }