summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-03-12 10:52:20 +0000
committerJim Meyering <jim@meyering.net>2001-03-12 10:52:20 +0000
commit97bfe9b9ddefce2c5857fb9745b2065e11c7247f (patch)
tree0202e0391a240db085bb5066e149db37726c33c2 /src
parenta40c539ad1885b8fe4e46d59cb38fbc68c692298 (diff)
downloadcoreutils-97bfe9b9ddefce2c5857fb9745b2065e11c7247f.tar.xz
(save_stdin): Use mkstemp to create temporary file.
Diffstat (limited to 'src')
-rw-r--r--src/tac.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/tac.c b/src/tac.c
index 09604049d..56ae74df4 100644
--- a/src/tac.c
+++ b/src/tac.c
@@ -1,5 +1,5 @@
/* tac - concatenate and print files in reverse
- Copyright (C) 1988-1991, 1995-2000 Free Software Foundation, Inc.
+ Copyright (C) 1988-1991, 1995-2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -72,8 +72,6 @@ tac -r -s '.\|
/* The number of bytes per atomic write. */
#define WRITESIZE 8192
-char *mktemp ();
-
/* The name this program was run with. */
char *program_name;
@@ -414,7 +412,7 @@ save_stdin (FILE **g_tmp, char **g_tempfile)
{
static char *template = NULL;
static char *tempdir;
- static char *tempfile;
+ char *tempfile;
FILE *tmp;
ssize_t bytes_read;
int fd;
@@ -427,11 +425,8 @@ save_stdin (FILE **g_tmp, char **g_tempfile)
template = xmalloc (strlen (tempdir) + 11);
}
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);
+ tempfile = template;
+ fd = mkstemp (template);
if (fd == -1)
error (EXIT_FAILURE, errno, "%s", tempfile);