chiark / gitweb /
shared: Use O_EXCL with O_TMPFILE in open_tmpfile
authorCristian Rodríguez <crrodriguez@opensuse.org>
Mon, 11 May 2015 18:01:37 +0000 (15:01 -0300)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 07:54:18 +0000 (08:54 +0100)
In this usecase, the file will never be materialized
with linkat().

src/shared/util.c

index e36389e..275fdec 100644 (file)
@@ -4839,7 +4839,7 @@ int open_tmpfile(const char *path, int flags) {
 
 #ifdef O_TMPFILE
         /* Try O_TMPFILE first, if it is supported */
-        fd = open(path, flags|O_TMPFILE, S_IRUSR|S_IWUSR);
+        fd = open(path, flags|O_TMPFILE|O_EXCL, S_IRUSR|S_IWUSR);
         if (fd >= 0)
                 return fd;
 #endif