dynamic config: fail on relative paths 02/191702/1
authorMichal Bloch <m.bloch@samsung.com>
Mon, 22 Oct 2018 10:25:11 +0000 (12:25 +0200)
committerMichal Bloch <m.bloch@samsung.com>
Mon, 22 Oct 2018 10:25:11 +0000 (12:25 +0200)
Change-Id: I50ca411b3268fdc25d1cb58a19f1dc8aa9752bbb
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
src/libdlog/dynamic_config.c
src/logctl/logctl.c

index 807a790..a552966 100644 (file)
@@ -79,7 +79,7 @@ bool __dynamic_config_create(struct log_config *config)
        assert(!inotify_path);
 
        const char *const extra_config_path = log_config_get(config, DYNAMIC_CONFIG_CONF_KEY);
-       if (!extra_config_path)
+       if (!extra_config_path || extra_config_path[0] != '/')
                return false;
 
        if (asprintf(&inotify_path, "%s/%s", extra_config_path, DYNAMIC_CONFIG_FILENAME) < 0) {
index cfe437c..b3278fa 100644 (file)
@@ -451,6 +451,10 @@ int main(int argc, const char **argv)
                printf("Dynamic config is disabled (\"%s\" not defined in config)\n", DYNAMIC_CONFIG_CONF_KEY);
                return EXIT_SUCCESS;
        }
+       if (extra_config_path[0] != '/') {
+               printf("Dynamic config: invalid path in (is \"%s\" but has to be absolute)\n", extra_config_path);
+               return EXIT_FAILURE;
+       }
 
        __attribute__ ((cleanup(free_ptr))) char *full_inotify_path = NULL;
        if (asprintf(&full_inotify_path, "%s/%s", extra_config_path, DYNAMIC_CONFIG_FILENAME) < 0) {