[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: temp file creation bug in diffutils 2.7
From: |
Paul Eggert |
Subject: |
Re: temp file creation bug in diffutils 2.7 |
Date: |
Wed, 27 Dec 2000 16:00:39 -0800 (PST) |
Thanks for your bug report. Your patch isn't portable, since not
every system has mkstemp. We'll use something like the following
patch instead.
@@ -1012,5 +955,16 @@ edit (left, lname, lline, llen, right, r
{
- FILE *tmp = ck_fopen (tmpname, "w+");
+ int fd;
+ FILE *tmp;
+
+#if defined O_CREAT && defined O_TRUNC && defined O_EXCL
+ /* Use O_EXCL to avoid race condition. */
+ fd = open (tmpname, O_RDWR | O_CREAT | O_TRUNC | O_EXCL,
+ S_IRUSR | S_IWUSR);
+#else
+ fd = creat (tmpname, S_IRUSR | S_IWUSR);
+#endif
+ if (fd < 0 || ! (tmp = fdopen (fd, "w+")))
+ perror_fatal (tmpname);
switch (cmd1)