From 676e20f6f648c596f8fea4945dd7f48a145ff3b5 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Tue, 7 Jan 2025 02:41:03 +0100 Subject: [PATCH] KDSingleApplicationLocalSocket: Use `sizeof(sockaddr_un::sun_path)` --- src/kdsingleapplication_localsocket.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/kdsingleapplication_localsocket.cpp b/src/kdsingleapplication_localsocket.cpp index 383f12d..42a49e4 100644 --- a/src/kdsingleapplication_localsocket.cpp +++ b/src/kdsingleapplication_localsocket.cpp @@ -30,9 +30,7 @@ #include #include #include -#if defined(Q_OS_LINUX) -#include -#endif +#include #endif #if defined(Q_OS_WIN) @@ -59,11 +57,7 @@ KDSingleApplicationLocalSocket::KDSingleApplicationLocalSocket(const QString &na #if defined(Q_OS_UNIX) // Make sure the socket name does not exceed the size of sockaddr_un.sun_path -#ifdef Q_OS_LINUX - constexpr int maxSocketNameLength = UNIX_PATH_MAX - 1; -#else - constexpr int maxSocketNameLength = 103; // BSD and macOS -#endif + constexpr int maxSocketNameLength = sizeof(sockaddr_un::sun_path) - 1; const int tempPathLength = QDir::cleanPath(QDir::tempPath()).length() + 1;