From 279de09cebc4bb5677ea0feb7e7881b31df3efa0 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Sat, 12 Mar 2016 20:49:59 +1000 Subject: [PATCH] * config.c: f2b_config_load() -- enhanced 'includes' option handling --- src/config.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/config.c b/src/config.c index 7953efa..ac70d80 100644 --- a/src/config.c +++ b/src/config.c @@ -236,6 +236,16 @@ f2b_config_load(f2b_config_t *config, const char *path, bool recursion) { fclose(f); if (recursion && config->main && (param = f2b_config_param_find(config->main->param, "includes"))) { + struct stat st; + if (stat(param->value, &st) != 0) { + f2b_log_msg(log_warn, "path in 'includes' option not exists, ignored"); + return true; + } + if (!S_ISDIR(st.st_mode)) { + f2b_log_msg(log_warn, "path in 'includes' option not a directory, ignored"); + return true; + } + /* process dir */ char pattern[PATH_MAX] = ""; glob_t globbuf; snprintf(pattern, sizeof(pattern), "%s/*.conf", param->value);