]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(xtmpfopen): Open temporary file exclusively, to
authorJim Meyering <jim@meyering.net>
Wed, 11 Mar 1998 11:53:29 +0000 (11:53 +0000)
committerJim Meyering <jim@meyering.net>
Wed, 11 Mar 1998 11:53:29 +0000 (11:53 +0000)
foil a common denial-of-service attack.
From Paul Eggert.

src/sort.c

index cbcbff1e72fbadd8ec67022e152c97473babb74a..fd1f4d0a0e259b3f4bf2fa191153f6034acc1db5 100644 (file)
@@ -346,7 +346,7 @@ xtmpfopen (const char *file)
   FILE *fp;
   int fd;
 
-  fd = open (file, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+  fd = open (file, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600);
   if (fd < 0 || (fp = fdopen (fd, "w")) == NULL)
     {
       error (0, errno, "%s", file);