Fix incorrect string length calculation.

Closes #1963. Thanks to twegener-embertec.
This commit is contained in:
Roger A. Light 2020-12-18 09:45:49 +00:00
parent e97cf6252e
commit 0ec258d01f
3 changed files with 4 additions and 5 deletions

View File

@ -824,8 +824,7 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S
<term><option>persistence_location</option> <replaceable>path</replaceable></term>
<listitem>
<para>The path where the persistence database should be
stored. Must end in a trailing slash. If not given,
then the current directory is used.</para>
stored. If not given, then the current directory is used.</para>
<para>This option applies globally.</para>

View File

@ -412,9 +412,9 @@
# the path.
#persistence_file mosquitto.db
# Location for persistent database. Must include trailing /
# Location for persistent database.
# Default is an empty string (current directory).
# Set to e.g. /var/lib/mosquitto/ if running as a proper service on Linux or
# Set to e.g. /var/lib/mosquitto if running as a proper service on Linux or
# similar.
#persistence_location

View File

@ -661,7 +661,7 @@ int config__read(struct mosquitto__config *config, bool reload)
}
mosquitto__free(config->persistence_filepath);
if(config->persistence_location && strlen(config->persistence_location)){
len = strlen(config->persistence_location) + strlen(config->persistence_file) + 1;
len = strlen(config->persistence_location) + strlen(config->persistence_file) + 2;
config->persistence_filepath = mosquitto__malloc(len);
if(!config->persistence_filepath) return MOSQ_ERR_NOMEM;
#ifdef WIN32