Fix key truncation logic for Windows QSystemSemaphore::platformSafeKey

The QSystemSemaphore::platformSafeKey was intended to truncate oversized
keys on Windows, but didn't. The fix is to make sure MAX_PATH is defined
when compiling on Windows.

Change-Id: I03f3bee901203d901bda05a841451c8a2d2f3924
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Jøger Hansegård 2023-08-11 10:27:42 +02:00
parent 8a3330be38
commit 73fd7f2d4a

View File

@ -18,6 +18,8 @@
// by-one bug in the kernel) the usable bytes are only 30.
# define SHM_NAME_MAX 30
# endif
#elif defined(Q_OS_WINDOWS)
# include "qt_windows.h"
#endif
#if QT_CONFIG(sharedmemory) || QT_CONFIG(systemsemaphore)
@ -194,7 +196,7 @@ QString QtIpcCommon::platformSafeKey(const QString &key, QtIpcCommon::IpcType ip
}
QString result = prefix + mid + payload;
#ifdef MAX_PATH
#ifdef Q_OS_WINDOWS
result.truncate(MAX_PATH);
#endif
return result;