From 0ec258d01ff195f9009660e495cafa3ced0bc597 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Fri, 18 Dec 2020 09:45:49 +0000 Subject: [PATCH] Fix incorrect string length calculation. Closes #1963. Thanks to twegener-embertec. --- man/mosquitto.conf.5.xml | 3 +-- mosquitto.conf | 4 ++-- src/conf.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/man/mosquitto.conf.5.xml b/man/mosquitto.conf.5.xml index 38affc75..db3bef1e 100644 --- a/man/mosquitto.conf.5.xml +++ b/man/mosquitto.conf.5.xml @@ -824,8 +824,7 @@ log_timestamp_format %Y-%m-%dT%H:%M:%S path The path where the persistence database should be - stored. Must end in a trailing slash. If not given, - then the current directory is used. + stored. If not given, then the current directory is used. This option applies globally. diff --git a/mosquitto.conf b/mosquitto.conf index ef390cb5..c1f17c1b 100644 --- a/mosquitto.conf +++ b/mosquitto.conf @@ -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 diff --git a/src/conf.c b/src/conf.c index 4eb70432..2c663a9a 100644 --- a/src/conf.c +++ b/src/conf.c @@ -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