Check for file==dir only when reading.

This commit is contained in:
Roger A. Light 2021-08-23 19:37:15 +01:00
parent ba2ca33671
commit 9526b4cf23

View File

@ -117,6 +117,7 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read)
} }
} }
#else #else
if(mode[0] == 'r'){
struct stat statbuf; struct stat statbuf;
if(stat(path, &statbuf) < 0){ if(stat(path, &statbuf) < 0){
return NULL; return NULL;
@ -126,6 +127,7 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read)
log__printf(NULL, MOSQ_LOG_ERR, "Error: %s is not a file.", path); log__printf(NULL, MOSQ_LOG_ERR, "Error: %s is not a file.", path);
return NULL; return NULL;
} }
}
if (restrict_read) { if (restrict_read) {
FILE *fptr; FILE *fptr;