From 9ae38788dc86716b32bc98ba1ab5c0f7c9e14f80 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 28 Jan 2020 16:17:28 +0000 Subject: [PATCH] Fix config->user not being freed on exit. Closes #1564. Thanks to back1127. --- ChangeLog.txt | 1 + src/conf.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 75a62899..dbf44168 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,7 @@ Broker: - Strip whitespace from end of config file string options. Closes #1566. - Satisfy valgrind when exiting on error due to not being able to open a listening socket, by calling freeaddrinfo. Closes #1565. +- Fix config->user not being freed on exit. Closes #1564. 1.6.8 - 20191128 diff --git a/src/conf.c b/src/conf.c index 8320f89d..6c4e4009 100644 --- a/src/conf.c +++ b/src/conf.c @@ -292,6 +292,7 @@ void config__cleanup(struct mosquitto__config *config) mosquitto__free(config->security_options.password_file); mosquitto__free(config->security_options.psk_file); mosquitto__free(config->pid_file); + mosquitto__free(config->user); if(config->listeners){ for(i=0; ilistener_count; i++){ mosquitto__free(config->listeners[i].host); @@ -536,7 +537,10 @@ int config__parse_args(struct mosquitto_db *db, struct mosquitto__config *config /* Default to drop to mosquitto user if we are privileged and no user specified. */ if(!config->user){ - config->user = "mosquitto"; + config->user = mosquitto__strdup("mosquitto"); + if(config->user == NULL){ + return MOSQ_ERR_NOMEM; + } } if(db->verbose){ config->log_type = INT_MAX;