]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
log: handle empty log name 3732/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 26 Mar 2021 11:10:02 +0000 (12:10 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 26 Mar 2021 11:21:48 +0000 (12:21 +0100)
Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32491
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/confile.c
src/lxc/log.c
src/tests/parse_config_file.c

index c4d3e2c637201f9e73aa995288578e16fbd9adaf..576e6f2d89cad6fd99939cc162ccd4db0d268c30 100644 (file)
@@ -1600,6 +1600,9 @@ static int set_config_log_file(const char *key, const char *value,
                return 0;
        }
 
+       if (!abspath(value))
+               return ret_errno(EINVAL);
+
        /*
         * Store these values in the lxc_conf, and then try to set for actual
         * current logging.
index 90a56e26a1b718f943e4c35f0b8803f8bd0910b7..4733fcdeb12afa1fcc6666b51dc831c5d51a6ca7 100644 (file)
@@ -489,6 +489,12 @@ static int build_dir(const char *name)
        __do_free char *n = NULL;
        char *e, *p;
 
+       if (is_empty_string(name))
+               return ret_errno(EINVAL);
+
+       if (!abspath(name))
+               return ret_errno(EINVAL);
+
        /* Make copy of the string since we'll be modifying it. */
        n = strdup(name);
        if (!n)
@@ -604,7 +610,7 @@ static int __lxc_log_set_file(const char *fname, int create_dirs)
        if (lxc_log_fd >= 0)
                lxc_log_close();
 
-       if (!fname)
+       if (is_empty_string(fname))
                return ret_errno(EINVAL);
 
        if (strlen(fname) == 0) {
@@ -820,6 +826,9 @@ int lxc_log_set_file(int *fd, const char *fname)
        if (*fd >= 0)
                close_prot_errno_disarm(*fd);
 
+       if (is_empty_string(fname))
+               return ret_errno(EINVAL);
+
        if (build_dir(fname))
                return -errno;
 
index 6d0e88805de3115b84198d81e4ed7cbf4324c802..0fa129500f851477365494c50b81a2207054594f 100644 (file)
@@ -899,6 +899,11 @@ int main(int argc, char *argv[])
                return -1;
        }
 
+       if (c->set_config_item(c, "lxc.log.file=", "./")) {
+               lxc_error("%s\n", "Managed to set to set invalid config item \"lxc.log.file\" to \"./\"");
+               return -1;
+       }
+
        fret = EXIT_SUCCESS;
 
 non_test_error: