diff --git a/src/pilerimport.c b/src/pilerimport.c index 49c17c09..7fc0acbd 100644 --- a/src/pilerimport.c +++ b/src/pilerimport.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -21,7 +22,7 @@ extern int optind; int import_message(char *filename, struct session_data *sdata, struct __data *data, struct __config *cfg){ - int rc=ERR; + int rc=ERR, fd; char *rule; struct stat st; struct _state state; @@ -44,7 +45,7 @@ int import_message(char *filename, struct session_data *sdata, struct __data *da else { if(stat(filename, &st) != 0){ - printf("cannot read: %s\n", filename); + printf("cannot stat() %s\n", filename); return rc; } @@ -53,6 +54,13 @@ int import_message(char *filename, struct session_data *sdata, struct __data *da return rc; } + fd = open(filename, O_RDONLY); + if(fd == -1){ + printf("cannot open %s\n", filename); + return rc; + } + close(fd); + snprintf(sdata->filename, SMALLBUFSIZE-1, "%s", filename); sdata->tot_len = st.st_size;