Strip whitespace from end of config file string options.

Closes #1566. Thanks to kollokollo.
This commit is contained in:
Roger A. Light 2020-01-28 16:04:25 +00:00
parent 6aa9b91fff
commit e7c9f009bd
2 changed files with 10 additions and 0 deletions

View File

@ -4,6 +4,8 @@ Broker:
- Use presence of password file as indicator for whether username checks
should take place, not whether usernames are defined in the password file.
Closes #1545.
- Strip whitespace from end of config file string options. Closes #1566.
1.6.8 - 20191128
================

View File

@ -2376,6 +2376,14 @@ static int conf__parse_string(char **token, const char *name, char **value, char
while((*token)[0] == ' ' || (*token)[0] == '\t'){
(*token)++;
}
if(strlen(*token) == 0){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Empty %s value in configuration.", name);
return MOSQ_ERR_INVAL;
}
while((*token)[strlen(*token)-1] == ' ' || (*token)[strlen(*token)-1] == '\t'){
(*token)[strlen(*token)-1] = '\0';
}
if(mosquitto_validate_utf8(*token, strlen(*token))){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Malformed UTF-8 in configuration.");
return MOSQ_ERR_INVAL;