libcommon: Use mosquitto_fopen in mosquitto_read_file

This commit is contained in:
Roger A. Light
2025-10-29 10:44:03 +00:00
parent 0dfbc7ab36
commit 6274730810
4 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -95,7 +95,7 @@ int load_file(const char *filename)
cfg.pub_mode = MSGMODE_FILE;
int rc = mosquitto_read_file(filename, &buf, &buflen);
int rc = mosquitto_read_file(filename, false, &buf, &buflen);
if(rc){
err_printf(&cfg, "Error: Unable to read file \"%s\": %s.\n", filename, mosquitto_strerror(rc));
return 1;
+1 -1
View File
@@ -51,7 +51,7 @@ libmosqcommon_EXPORT int mosquitto_write_file(const char *target_path, bool rest
/*
* Function: mosquitto_read_file
*/
libmosqcommon_EXPORT int mosquitto_read_file(const char *file, char **buf, size_t *buflen);
libmosqcommon_EXPORT int mosquitto_read_file(const char *file, bool restrict_read, char **buf, size_t *buflen);
/*
+2 -2
View File
@@ -425,14 +425,14 @@ error:
}
int mosquitto_read_file(const char *file, char **buf, size_t *buflen)
int mosquitto_read_file(const char *file, bool restrict_read, char **buf, size_t *buflen)
{
FILE *fptr;
long l;
size_t buflen_i;
*buf = NULL;
fptr = fopen(file, "rt");
fptr = mosquitto_fopen(file, "rt", restrict_read);
if(fptr == NULL){
return MOSQ_ERR_ERRNO;
}
+2 -2
View File
@@ -446,11 +446,11 @@ int http_api__start(struct mosquitto__listener *listener)
port = listener->port;
if(listener->certfile && listener->keyfile){
if(mosquitto_read_file(listener->certfile, &x509_cert, NULL)){
if(mosquitto_read_file(listener->certfile, false, &x509_cert, NULL)){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Unable to load server certificate \"%s\". Check certfile.", listener->certfile);
return MOSQ_ERR_INVAL;
}
if(mosquitto_read_file(listener->keyfile, &x509_key, NULL)){
if(mosquitto_read_file(listener->keyfile, false, &x509_key, NULL)){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Unable to load server key file \"%s\". Check keyfile.", listener->keyfile);
mosquitto_FREE(x509_cert);
return MOSQ_ERR_INVAL;