diff options
author | jvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-03-13 17:38:07 +0000 |
---|---|---|
committer | jvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-03-13 17:38:07 +0000 |
commit | 922c7033b7307972e6c727ca5ab03d97c0048a9c (patch) | |
tree | 7880c8ac436cbf2e236c6f8336abc9f0d89b53eb /gcc/fortran/scanner.c | |
parent | fd4ab6d9ce9d96ebfb00b5a0ad60fd47a04b4a35 (diff) |
2016-03-13 Jerry DeLisle <jvdelisle@gcc.gnu.org>
Jim MacArthur <jim.macarthur@codethink.co.uk>
PR fortran/69043
* scanner.c (load_file): Check that included file is regular.
PR fortran/69043
* gfortran.dg/include_9.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234169 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/scanner.c')
-rw-r--r-- | gcc/fortran/scanner.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c index c4e7974ed4a5..33d96d88d922 100644 --- a/gcc/fortran/scanner.c +++ b/gcc/fortran/scanner.c @@ -2200,6 +2200,8 @@ load_file (const char *realfilename, const char *displayedname, bool initial) FILE *input; int len, line_len; bool first_line; + struct stat st; + int stat_result; const char *filename; /* If realfilename and displayedname are different and non-null then surely realfilename is the preprocessed form of @@ -2227,6 +2229,7 @@ load_file (const char *realfilename, const char *displayedname, bool initial) } else input = gfc_open_file (realfilename); + if (input == NULL) { gfc_error_now ("Can't open file %qs", filename); @@ -2242,6 +2245,15 @@ load_file (const char *realfilename, const char *displayedname, bool initial) current_file->filename, current_file->line, filename); return false; } + stat_result = stat (realfilename, &st); + if (stat_result == 0 && !(st.st_mode & S_IFREG)) + { + fprintf (stderr, "%s:%d: Error: Included path '%s'" + " is not a regular file\n", + current_file->filename, current_file->line, filename); + fclose (input); + return false; + } } /* Load the file. |