]> git.wh0rd.org Git - nano.git/commitdiff
Okay, we'll use O_EXCL also
authorChris Allegretta <chrisa@asty.org>
Mon, 4 Dec 2000 05:25:47 +0000 (05:25 +0000)
committerChris Allegretta <chrisa@asty.org>
Mon, 4 Dec 2000 05:25:47 +0000 (05:25 +0000)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@383 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
files.c

index 4e7d6d1f097116a5686c0a64e529f21d6e5ac617..6a1571737a19606e869dce81d7ae2718df47f76f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,7 +3,7 @@ CVS code -
   write_file()
        - Added tmp check to TMP_OPT section (how apropriate).
        - Added new consistency checking code from securityfocus 
-         article by Oliver Friedrichs.
+         article by Oliver Friedrichs, and use O_EXCL if tmp == 1.
 - winio.c:
   edit_add()
        - Off by one display error (fix by Rocco Corsi).
diff --git a/files.c b/files.c
index 0b38e3b5e522be2b810bd1c2c312aa27f8463016..c0299e4060544ce6db580767bb7d05c09bca3516 100644 (file)
--- a/files.c
+++ b/files.c
@@ -334,7 +334,13 @@ int write_file(char *name, int tmp)
         return -1;
     else if (ISSET(FOLLOW_SYMLINKS) || !S_ISLNK(st.st_mode)) {
 
-       fd = open(realname, O_WRONLY | O_CREAT | O_TRUNC,
+       /* Use O_EXCL if tmp == 1, I suppose */
+       if (tmp)
+           fd = open(realname, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC,
+                       S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
+                       S_IWOTH);
+       else 
+           fd = open(realname, O_WRONLY | O_CREAT | O_TRUNC,
                        S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
                        S_IWOTH);