diff --git a/src/libs/zbxcfg/cfg.c b/src/libs/zbxcfg/cfg.c index 29b661deda9..456c0587abf 100644 --- a/src/libs/zbxcfg/cfg.c +++ b/src/libs/zbxcfg/cfg.c @@ -426,9 +426,9 @@ static int __parse_cfg_file(const char *cfg_file, struct cfg_line *cfg, int leve FILE *file; int i, lineno, param_valid; - char line[MAX_STRING_LEN + 3], *parameter, *value; + char line[MAX_STRING_LEN + 3], *parameter, *value, *cfg_options_read; zbx_uint64_t var; - size_t len; + size_t len, cfg_size = 0; #ifdef _WINDOWS wchar_t *wcfg_file; #endif @@ -438,6 +438,11 @@ static int __parse_cfg_file(const char *cfg_file, struct cfg_line *cfg, int leve return FAIL; } + for (i = 0; NULL != cfg[i].parameter; i++) + cfg_size++; + + cfg_options_read = calloc(cfg_size, sizeof(*cfg_options_read)); + if (NULL != cfg_file) { #ifdef _WINDOWS @@ -497,6 +502,18 @@ static int __parse_cfg_file(const char *cfg_file, struct cfg_line *cfg, int leve if (0 != strcmp(cfg[i].parameter, parameter)) continue; + if (TYPE_MULTISTRING != cfg[i].type && TYPE_CUSTOM != cfg[i].type) + { + if (0 != cfg_options_read[i]) + { + zabbix_log(LOG_LEVEL_WARNING, "parameter %s is listed more than once at" + " line %d, previous values will be ignored", + parameter, lineno); + } + + cfg_options_read[i] = 1; + } + param_valid = 1; zabbix_log(LOG_LEVEL_DEBUG, "accepted configuration parameter: '%s' = '%s'", @@ -582,6 +599,8 @@ static int __parse_cfg_file(const char *cfg_file, struct cfg_line *cfg, int leve } } + zbx_free(cfg_options_read); + return SUCCEED; cannot_open: if (ZBX_CFG_FILE_REQUIRED != optional) @@ -612,6 +631,8 @@ unknown_parameter: missing_mandatory: zbx_error("missing mandatory parameter \"%s\" in config file \"%s\"", cfg[i].parameter, cfg_file); error: + zbx_free(cfg_options_read); + if (0 == noexit) exit(EXIT_FAILURE);