summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2017-06-19 20:39:19 +0200
committerTomaž Vajngerl <quikee@gmail.com>2017-07-05 16:56:20 +0200
commitc3a4dacfa0aae3cf40aa7b123672c6bc197efe0f (patch)
tree1269ea7cfc46741d872d62e94f09ece787b15dfc /sal
parenteda1190de3f7cdd9abeb0a31fb3b2791ce418aab (diff)
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@collabora.com> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/file.cxx4
1 files changed, 4 insertions, 0 deletions
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 );