From: Michal Bloch Date: Mon, 22 Oct 2018 10:25:11 +0000 (+0200) Subject: dynamic config: fail on relative paths X-Git-Tag: accepted/tizen/unified/20181105.143907~5^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0b15e50e5a3897a29cb6051c06a5cd018d45f913;p=platform%2Fcore%2Fsystem%2Fdlog.git dynamic config: fail on relative paths Change-Id: I50ca411b3268fdc25d1cb58a19f1dc8aa9752bbb Signed-off-by: Michal Bloch --- diff --git a/src/libdlog/dynamic_config.c b/src/libdlog/dynamic_config.c index 807a790..a552966 100644 --- a/src/libdlog/dynamic_config.c +++ b/src/libdlog/dynamic_config.c @@ -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) { diff --git a/src/logctl/logctl.c b/src/logctl/logctl.c index cfe437c..b3278fa 100644 --- a/src/logctl/logctl.c +++ b/src/logctl/logctl.c @@ -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) {