parser-helper: Don't attempt to open anything but regular files
A crash could be provoked e.g. via STRONGSWAN_CONF=. or any other path to a directory.
This commit is contained in:
parent
991e9e5dc9
commit
a59842eb95
|
@ -16,6 +16,8 @@
|
|||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "parser_helper.h"
|
||||
|
||||
|
@ -93,6 +95,7 @@ METHOD(parser_helper_t, file_next, FILE*,
|
|||
private_parser_helper_t *this)
|
||||
{
|
||||
parser_helper_file_t *file, *next;
|
||||
struct stat st;
|
||||
char *name;
|
||||
|
||||
array_get(this->files, ARRAY_TAIL, &file);
|
||||
|
@ -112,7 +115,8 @@ METHOD(parser_helper_t, file_next, FILE*,
|
|||
.file = fopen(name, "r"),
|
||||
);
|
||||
|
||||
if (next->file)
|
||||
if (next->file && fstat(fileno(next->file), &st) == 0 &&
|
||||
S_ISREG(st.st_mode))
|
||||
{
|
||||
array_insert(this->files, ARRAY_TAIL, next);
|
||||
return next->file;
|
||||
|
|
Loading…
Reference in New Issue