From 73fd7f2d4a3b5c2441bb98268d30f8abfd604b14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8ger=20Hanseg=C3=A5rd?= Date: Fri, 11 Aug 2023 10:27:42 +0200 Subject: [PATCH] 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 --- src/corelib/ipc/qtipccommon.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/ipc/qtipccommon.cpp b/src/corelib/ipc/qtipccommon.cpp index a2cc75b4b1..36d3bfc9a6 100644 --- a/src/corelib/ipc/qtipccommon.cpp +++ b/src/corelib/ipc/qtipccommon.cpp @@ -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;