From e7c9f009bd59b316ca50ece5275d12350f7ee6dc Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 28 Jan 2020 16:04:25 +0000 Subject: [PATCH] Strip whitespace from end of config file string options. Closes #1566. Thanks to kollokollo. --- ChangeLog.txt | 2 ++ src/conf.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 262d305f..8ea45d64 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -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 ================ diff --git a/src/conf.c b/src/conf.c index 8b6eb59b..8320f89d 100644 --- a/src/conf.c +++ b/src/conf.c @@ -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;