Commit a0ceafd1 by Tobias Burnus Committed by Tobias Burnus

re PR fortran/54878 (libgfortran issues found by the Coverity scanner)

2012-10-10  Tobias Burnus  <burnus@net-b.de>

	PR fortran/54878
	* io/unix.c (tempfile_open): Set umask before calling mkstemp.

From-SVN: r192325
parent fb8bf47a
2012-10-10 Tobias Burnus <burnus@net-b.de>
PR fortran/54878
* io/unix.c (tempfile_open): Set umask before calling mkstemp.
2012-10-06 Janne Blomqvist <jb@gcc.gnu.org> 2012-10-06 Janne Blomqvist <jb@gcc.gnu.org>
* configure.ac: Check for presence of secure_getenv. * configure.ac: Check for presence of secure_getenv.
......
...@@ -1051,6 +1051,9 @@ tempfile_open (const char *tempdir, char **fname) ...@@ -1051,6 +1051,9 @@ tempfile_open (const char *tempdir, char **fname)
{ {
int fd; int fd;
const char *slash = "/"; const char *slash = "/";
#if defined(HAVE_UMASK) && defined(HAVE_MKSTEMP)
mode_t mode_mask;
#endif
if (!tempdir) if (!tempdir)
return -1; return -1;
...@@ -1072,8 +1075,17 @@ tempfile_open (const char *tempdir, char **fname) ...@@ -1072,8 +1075,17 @@ tempfile_open (const char *tempdir, char **fname)
snprintf (template, tempdirlen + 23, "%s%sgfortrantmpXXXXXX", snprintf (template, tempdirlen + 23, "%s%sgfortrantmpXXXXXX",
tempdir, slash); tempdir, slash);
#ifdef HAVE_UMASK
/* Temporarily set the umask such that the file has 0600 permissions. */
mode_mask = umask (S_IXUSR | S_IRWXG | S_IRWXO);
#endif
fd = mkstemp (template); fd = mkstemp (template);
#ifdef HAVE_UMASK
(void) umask (mode_mask);
#endif
#else /* HAVE_MKSTEMP */ #else /* HAVE_MKSTEMP */
fd = -1; fd = -1;
int count = 0; int count = 0;
......
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