Make sure that files included in settings_t are regular files.
This commit is contained in:
@@ -22,6 +22,9 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <glob.h>
|
#include <glob.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
@@ -914,14 +917,30 @@ static bool parse_file(linked_list_t *contents, char *file, int level,
|
|||||||
{
|
{
|
||||||
bool success;
|
bool success;
|
||||||
char *text, *pos;
|
char *text, *pos;
|
||||||
|
struct stat st;
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
DBG2(DBG_LIB, "loading config file '%s'", file);
|
DBG2(DBG_LIB, "loading config file '%s'", file);
|
||||||
|
if (stat(file, &st) == -1)
|
||||||
|
{
|
||||||
|
if (errno == ENOENT)
|
||||||
|
{
|
||||||
|
DBG2(DBG_LIB, "'%s' does not exist, ignored", file);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
DBG1(DBG_LIB, "failed to stat '%s': %s", file, strerror(errno));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
else if (!S_ISREG(st.st_mode))
|
||||||
|
{
|
||||||
|
DBG1(DBG_LIB, "'%s' is not a regular file", file);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
fd = fopen(file, "r");
|
fd = fopen(file, "r");
|
||||||
if (fd == NULL)
|
if (fd == NULL)
|
||||||
{
|
{
|
||||||
DBG1(DBG_LIB, "'%s' does not exist or is not readable", file);
|
DBG1(DBG_LIB, "'%s' is not readable", file);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
fseek(fd, 0, SEEK_END);
|
fseek(fd, 0, SEEK_END);
|
||||||
|
|||||||
Reference in New Issue
Block a user