Skip to content

Commit

Permalink
KDSingleApplicationLocalSocket: Use sizeof(sockaddr_un::sun_path)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaski authored and nicolasfella committed Jan 15, 2025
1 parent 24ad34a commit 676e20f
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/kdsingleapplication_localsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <pwd.h>
#if defined(Q_OS_LINUX)
#include <linux/un.h>
#endif
#include <sys/un.h>
#endif

#if defined(Q_OS_WIN)
Expand All @@ -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;

Expand Down

0 comments on commit 676e20f

Please sign in to comment.