path: root/src/corelib/kernel/qcore_unix_p.h
diff options
authorThiago Macieira <>2018-07-13 00:26:30 -0700
committerThiago Macieira <>2018-07-17 22:23:06 +0000
commit1d33493989eae774bafc124f9d3ee68d7a017a10 (patch)
treefbae955b046e45b3d7b979f71e4a9999c4f72a99 /src/corelib/kernel/qcore_unix_p.h
parente20307dcfbd30fbc4f43dfb3626f440a48567416 (diff)
Linux: Bypass glibc's broken open() implementation
Glibc 2.21 and earlier have a bug that leaves the mode parameter unset when O_TMPFILE is used. So we bypass the glibc implementation and go directly for the syscall. We do this only for 32-bit x86, since of the current, modern platforms, it's the only one that passes parameters on the stack. Technically speaking, the glibc bug applies to all platforms, but it turns out that on all others, it appears to work. By doing this, we have two minor differences: 1) open() is a cancellation point, but syscall() isn't 2) if anyone tries to intercept open() calls via LD_PRELOAD, they're not going to catch Qt's. [ChangeLog][QtCore][QTemporaryFile] Worked around a bug in the GNU C Library versions 2.21 and earlier (used on Linux) that caused temporary files to be created with permissions 000. Task-number: QTBUG-69436 Change-Id: I20fd00e600264ff98c6afffd1540dceea89fa91f Reviewed-by: Simon Hausmann <>
Diffstat (limited to 'src/corelib/kernel/qcore_unix_p.h')
1 files changed, 8 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index e538a7e22b..cb98bef347 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -176,6 +176,14 @@ inline void qt_ignore_sigpipe()
+#if defined(Q_PROCESSOR_X86_32) && defined(__GLIBC__)
+# if !__GLIBC_PREREQ(2, 22)
+int qt_open64(const char *pathname, int flags, mode_t);
+# undef QT_OPEN
+# define QT_OPEN qt_open64
+# endif
// don't call QT_OPEN or ::open
// call qt_safe_open
static inline int qt_safe_open(const char *pathname, int flags, mode_t mode = 0777)