From: Jim Meyering Date: Wed, 11 Mar 1998 11:53:29 +0000 (+0000) Subject: (xtmpfopen): Open temporary file exclusively, to X-Git-Tag: FILEUTILS-3_16n~50 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=7ee8ed7e378e2a5a9495bc17692fc41f266c14ac;p=thirdparty%2Fcoreutils.git (xtmpfopen): Open temporary file exclusively, to foil a common denial-of-service attack. From Paul Eggert. --- diff --git a/src/sort.c b/src/sort.c index cbcbff1e72..fd1f4d0a0e 100644 --- a/src/sort.c +++ b/src/sort.c @@ -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);