diff --git a/ChangeLog.txt b/ChangeLog.txt index 03855e7d..3711c6d4 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -92,6 +92,7 @@ Broker: - Default for max_queued_messages has been changed to 1000. - Add `ciphers_tls1.3` option, to allow setting TLS v1.3 ciphersuites. Closes #1825. +- Report an error if the config file is set to a directory. Closes #1814. Client library: - Client no longer generates random client ids for v3.1.1 clients, these are diff --git a/src/conf.c b/src/conf.c index aca38d02..ea73f916 100644 --- a/src/conf.c +++ b/src/conf.c @@ -2174,6 +2174,18 @@ int config__read_file(struct mosquitto__config *config, bool reload, const char FILE *fptr = NULL; char *buf; int buflen; +#ifndef WIN32 + DIR *dir; +#endif + +#ifndef WIN32 + dir = opendir(file); + if(dir){ + closedir(dir); + log__printf(NULL, MOSQ_LOG_ERR, "Error: Config file %s is a directory.", file); + return 1; + } +#endif fptr = mosquitto__fopen(file, "rt", false); if(!fptr){