diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2008-07-31 18:56:35 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2008-07-31 20:56:35 +0200 |
commit | a23eb008dc764028d758ef589f67aa822a2a81e1 (patch) | |
tree | 045aa0e1e55c97d4b396045787792803939cc6a8 /libiberty/make-temp-file.c | |
parent | 93cc82d1f3d649ad736c07396f711c9f09e67dbd (diff) | |
download | gcc-a23eb008dc764028d758ef589f67aa822a2a81e1.tar.gz |
mkstemps.c (mkstemps): If open failed with errno other than EEXIST, return immediately.
* mkstemps.c (mkstemps): If open failed with errno other than
EEXIST, return immediately.
* make-temp-file.c: Include errno.h.
(make_temp_file): If mkstemps failed, print an error message
before aborting.
From-SVN: r138429
Diffstat (limited to 'libiberty/make-temp-file.c')
-rw-r--r-- | libiberty/make-temp-file.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libiberty/make-temp-file.c b/libiberty/make-temp-file.c index 5e21414ad8e..94c76d700bd 100644 --- a/libiberty/make-temp-file.c +++ b/libiberty/make-temp-file.c @@ -23,6 +23,7 @@ Boston, MA 02110-1301, USA. */ #include <stdio.h> /* May get P_tmpdir. */ #include <sys/types.h> +#include <errno.h> #ifdef HAVE_UNISTD_H #include <unistd.h> #endif @@ -166,11 +167,14 @@ make_temp_file (const char *suffix) strcpy (temp_filename + base_len + TEMP_FILE_LEN, suffix); fd = mkstemps (temp_filename, suffix_len); - /* If mkstemps failed, then something bad is happening. Maybe we should - issue a message about a possible security attack in progress? */ + /* Mkstemps failed. It may be EPERM, ENOSPC etc. */ if (fd == -1) - abort (); - /* Similarly if we can not close the file. */ + { + fprintf (stderr, "Cannot create temporary file in %s: %s\n", + base, strerror (errno)); + abort (); + } + /* We abort on failed close out of sheer paranoia. */ if (close (fd)) abort (); return temp_filename; |