mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-09-26 03:43:47 +08:00
libcommon: Use mosquitto_fopen in mosquitto_read_file
This commit is contained in:
+1
-1
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user