[Libreoffice-commits] core.git: sal/osl

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Wed Jul 5 14:56:51 UTC 2017


 sal/osl/unx/file.cxx |    4 ++++
 1 file changed, 4 insertions(+)

New commits:
commit c3a4dacfa0aae3cf40aa7b123672c6bc197efe0f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Mon Jun 19 20:39:19 2017 +0200

    tdf#59424 unset open flag O_EXCL if O_CREAT is not set
    
    If O_EXCL is set and O_CREAT is not, then the behaviour is
    undefined. See open(3) man page.
    
    Change-Id: If61aaf0a0e46babae7df7e17ffbdcb4c81ab6a3c
    Reviewed-on: https://gerrit.libreoffice.org/38978
    Reviewed-by: Tor Lillqvist <tml at collabora.com>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    Tested-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index 7225b9326b6b..6d8aba858d95 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -936,6 +936,10 @@ oslFileError openFilePath(const char *cpFilePath, oslFileHandle* pHandle, sal_uI
         flags = osl_file_adjustLockFlags (cpFilePath, flags);
     }
 
+    // O_EXCL can be set only when O_CREAT is set
+    if (flags & O_EXCL && !(flags & O_CREAT))
+        flags &= ~O_EXCL;
+
     /* open the file */
     int fd = open_c( cpFilePath, flags, mode );
 


More information about the Libreoffice-commits mailing list