1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-05-31 23:06:33 +02:00

add comment about opening exclusively

This commit is contained in:
Jim Meyering
1998-12-13 19:26:35 +00:00
parent c5195207db
commit 7dfd5ca1cd
2 changed files with 4 additions and 0 deletions
+2
View File
@@ -340,6 +340,8 @@ xtmpfopen (const char *file)
FILE *fp;
int fd;
/* Open temporary file exclusively, to foil a common
denial-of-service attack. */
fd = open (file, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600);
if (fd < 0 || (fp = fdopen (fd, "w")) == NULL)
{
+2
View File
@@ -394,6 +394,8 @@ save_stdin (FILE **g_tmp, char **g_tempfile)
sprintf (template, "%s/tacXXXXXX", tempdir);
tempfile = mktemp (template);
/* Open temporary file exclusively, to foil a common
denial-of-service attack. */
fd = open (tempfile, O_RDWR | O_CREAT | O_TRUNC | O_EXCL, 0600);
if (fd == -1)
error (EXIT_FAILURE, errno, "%s", tempfile);