From: Jim Meyering Date: Wed, 11 Mar 1998 11:54:11 +0000 (+0000) Subject: (save_stdin): Open temporary file exclusively, to X-Git-Tag: FILEUTILS-3_16n~49 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cb3b5ed48689e9dbd24089451839d0ad290b8a9e;p=thirdparty%2Fcoreutils.git (save_stdin): Open temporary file exclusively, to foil a common denial-of-service attack. From Paul Eggert. --- diff --git a/src/tac.c b/src/tac.c index f55fb6ffb2..fcd8e547c8 100644 --- a/src/tac.c +++ b/src/tac.c @@ -418,7 +418,7 @@ save_stdin (FILE **g_tmp, char **g_tempfile) sprintf (template, "%s/tacXXXXXX", tempdir); tempfile = mktemp (template); - fd = creat (tempfile, 0600); + fd = open (tempfile, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600); if (fd == -1 || (tmp = fdopen (fd, "rw")) == NULL) error (EXIT_FAILURE, errno, "%s", tempfile); tmp = fdopen (fd, "rw");