diff options
author | Tobias Burnus <burnus@net-b.de> | 2012-10-10 20:42:34 +0200 |
---|---|---|
committer | Tobias Burnus <burnus@gcc.gnu.org> | 2012-10-10 20:42:34 +0200 |
commit | a0ceafd19b0a33df40493df9f84f4a2866f6be5c (patch) | |
tree | d863c9dbd5ed9572a7306a41426ddf45343735cf /libgfortran/io/unix.c | |
parent | fb8bf47a348997eb3912fcc8c3a983339c3aad07 (diff) | |
download | gcc-a0ceafd19b0a33df40493df9f84f4a2866f6be5c.zip gcc-a0ceafd19b0a33df40493df9f84f4a2866f6be5c.tar.gz gcc-a0ceafd19b0a33df40493df9f84f4a2866f6be5c.tar.bz2 |
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
Diffstat (limited to 'libgfortran/io/unix.c')
-rw-r--r-- | libgfortran/io/unix.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c index 805d4bb..9d2e9d8 100644 --- a/libgfortran/io/unix.c +++ b/libgfortran/io/unix.c @@ -1051,6 +1051,9 @@ tempfile_open (const char *tempdir, char **fname) { int fd; const char *slash = "/"; +#if defined(HAVE_UMASK) && defined(HAVE_MKSTEMP) + mode_t mode_mask; +#endif if (!tempdir) return -1; @@ -1072,8 +1075,17 @@ tempfile_open (const char *tempdir, char **fname) snprintf (template, tempdirlen + 23, "%s%sgfortrantmpXXXXXX", 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); +#ifdef HAVE_UMASK + (void) umask (mode_mask); +#endif + #else /* HAVE_MKSTEMP */ fd = -1; int count = 0; |