diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2017-05-16 23:40:15 -0700 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-05-18 21:17:52 +0000 |
commit | 9406bef6b33b1b9c2d8bb64200266a8449eced4a (patch) | |
tree | c2049e68214ce566c2d9fb57192ceb85b7cbf3ba | |
parent | fc874c2976b9e066879ff22e23e6e99a65d22dfc (diff) |
Revert "Add qt_safe_ftok wrapper for ftok"
This reverts commit ac0184d6085d9e4f7f59352e563055311f4d8792. That
commit added the use of qHash in qt_safe_ftok, which made ftok even more
unsafe than previously. Since the algorithm in qHash can change across
Qt versions, we need a stable algorithm instead.
[ChangeLog][Important Behavior Changes] Reverted a change that caused Qt
5.6 through 5.8 not to connect to QSystemSemaphore and QSharedMemory
created by running applications using Qt earlier than
5.6. Unfortunately, this means that Qt 5.9 will not connect to 5.6-5.8.
Task-number: QTBUG-60771
Change-Id: Ibc3472e1c11d46358357fffd14bf51aeb48ef2c8
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r-- | dist/changes-5.9.0 | 4 | ||||
-rw-r--r-- | src/corelib/kernel/qcore_unix_p.h | 14 | ||||
-rw-r--r-- | src/corelib/kernel/qsharedmemory_systemv.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qsystemsemaphore_systemv.cpp | 2 |
4 files changed, 6 insertions, 16 deletions
diff --git a/dist/changes-5.9.0 b/dist/changes-5.9.0 index 3545ed411c..6d13e5c6ce 100644 --- a/dist/changes-5.9.0 +++ b/dist/changes-5.9.0 @@ -32,6 +32,10 @@ information about a particular change. - [QTBUG-59849] QSysInfo::productType() and QFileSelector behavior on macOS was restored to match what Qt used to return in version 5.7.0 and earlier. The behavior found in Qt 5.6.2, 5.7.1 and 5.8.0 is removed. + - [QTBUG-60771] Reverted a change that caused Qt 5.6 through 5.8 not to + connect to QSystemSemaphore and QSharedMemory created by running + applications using Qt earlier than 5.6. Unfortunately, this means that Qt + 5.9 will not connect to 5.6-5.8. - QTouchEvent * Touch point ids are now unique even between different devices. As a diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index 8f37aec6e2..86bace3260 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -55,7 +55,6 @@ #include <QtCore/private/qglobal_p.h> #include "qplatformdefs.h" #include "qatomic.h" -#include "qhash.h" #ifndef Q_OS_UNIX # error "qcore_unix_p.h included on a non-Unix system" @@ -369,19 +368,6 @@ union qt_semun { unsigned short *array; /* array for GETALL, SETALL */ }; -#ifndef QT_POSIX_IPC -#if QT_CONFIG(sharedmemory) || QT_CONFIG(systemsemaphore) -#ifndef Q_OS_ANDROID -static inline key_t qt_safe_ftok(const QByteArray &filename, int proj_id) -{ - // Unfortunately ftok can return colliding keys even for different files. - // Try to add some more entropy via qHash. - return ::ftok(filename.constData(), qHash(filename, proj_id)); -} -#endif // !Q_OS_ANDROID -#endif // QT_CONFIG(sharedmemory) || QT_CONFIG(systemsemaphore) -#endif // !QT_POSIX_IPC - QT_END_NAMESPACE #endif diff --git a/src/corelib/kernel/qsharedmemory_systemv.cpp b/src/corelib/kernel/qsharedmemory_systemv.cpp index 339ee9afe2..fea4a65b5c 100644 --- a/src/corelib/kernel/qsharedmemory_systemv.cpp +++ b/src/corelib/kernel/qsharedmemory_systemv.cpp @@ -88,7 +88,7 @@ key_t QSharedMemoryPrivate::handle() return 0; } - unix_key = qt_safe_ftok(QFile::encodeName(nativeKey), 'Q'); + unix_key = ftok(QFile::encodeName(nativeKey).constData(), 'Q'); if (-1 == unix_key) { errorString = QSharedMemory::tr("%1: ftok failed").arg(QLatin1String("QSharedMemory::handle:")); error = QSharedMemory::KeyError; diff --git a/src/corelib/kernel/qsystemsemaphore_systemv.cpp b/src/corelib/kernel/qsystemsemaphore_systemv.cpp index 83da09da44..9e438ae2a6 100644 --- a/src/corelib/kernel/qsystemsemaphore_systemv.cpp +++ b/src/corelib/kernel/qsystemsemaphore_systemv.cpp @@ -104,7 +104,7 @@ key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode) #if !defined(QT_NO_SHAREDMEMORY) && !defined(QT_POSIX_IPC) && !defined(Q_OS_ANDROID) // Get the unix key for the created file - unix_key = qt_safe_ftok(QFile::encodeName(fileName), 'Q'); + unix_key = ftok(QFile::encodeName(fileName).constData(), 'Q'); #endif if (-1 == unix_key) { errorString = |