MXS-1731: Treat empty parameters as errors

If a parameter is defined without a value, it is now treated as an error.
This commit is contained in:
Markus Mäkelä
2018-03-21 09:42:56 +02:00
committed by Johan Wikman
parent 436c563da7
commit 433528aa59
4 changed files with 81 additions and 2 deletions

View File

@ -463,6 +463,19 @@ void fix_section_name(char *section)
replace_whitespace(section);
}
static bool is_empty_string(const char* str)
{
for (const char* p = str; *p; p++)
{
if (!isspace(*p))
{
return false;
}
}
return true;
}
/**
* Config item handler for the ini file reader
*
@ -477,6 +490,12 @@ static int ini_handler(void *userdata, const char *section, const char *name, co
CONFIG_CONTEXT *cntxt = (CONFIG_CONTEXT *)userdata;
CONFIG_CONTEXT *ptr = cntxt;
if (is_empty_string(value))
{
MXS_ERROR("Empty value given to parameter '%s'", name);
return 0;
}
if (config_get_global_options()->substitute_variables)
{
if (*value == '$')