Commit 44e66a77 by Jerry DeLisle

re PR fortran/69043 (Trying to include a directory causes an infinite loop)

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.

Co-Authored-By: Jim MacArthur <jim.macarthur@codethink.co.uk>

From-SVN: r234169
parent a18e0fe1
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.
2016-03-12 Jerry DeLisle <jvdelisle@gcc.gnu.org>
Harold Anlauf <anlauf@gmx.de>
......
......@@ -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.
......
2016-03-13 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/69043
* gfortran.dg/include_9.f90: New test.
2016-03-13 Dominique d'Humieres <dominiq@lps.ens.fr>
PR fortran/45076
......
! { dg-do compile }
! PR69043 Trying to include a directory causes an infinite loop
include '.'
program main
end program
! { dg-error "is not a regular file" " " { target *-*-* } 3 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment