From 7dfd5ca1cd8db43dae50c6f0a5d3038bcc6a0a5f Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 13 Dec 1998 19:26:35 +0000 Subject: [PATCH] add comment about opening exclusively --- src/sort.c | 2 ++ src/tac.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/sort.c b/src/sort.c index 3446abdc9d..d6ce76d9ca 100644 --- a/src/sort.c +++ b/src/sort.c @@ -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) { diff --git a/src/tac.c b/src/tac.c index 0aefe8d86b..06deca2e20 100644 --- a/src/tac.c +++ b/src/tac.c @@ -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); -- 2.47.3