Skip to content

Commit b51cc75

Browse files
committed
Detect singleton socket path being too long
Somehow bind() has the same filename length limit from the 1970s and there is no alternative API that can use a longer name. Recent MacOS versions generate a long random path for TMPDIR, which causes a fatal error for daemonded - #1390 (the server uses a slightly longer path than the client).
1 parent a4089d6 commit b51cc75

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/engine/framework/System.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ static bool ConnectSingletonSocket()
156156

157157
struct sockaddr_un addr;
158158
addr.sun_family = AF_UNIX;
159+
if (singletonSocketPath.size() > sizeof(addr.sun_path)) {
160+
Sys::Error("Singleton socket name '%s' is too long. Try configuring a shorter $TMPDIR",
161+
singletonSocketPath);
162+
}
159163
Q_strncpyz(addr.sun_path, singletonSocketPath.c_str(), sizeof(addr.sun_path));
160164
if (connect(singletonSocket, reinterpret_cast<struct sockaddr*>(&addr), sizeof(addr)) == -1) {
161165
if (errno != ENOENT)

0 commit comments

Comments
 (0)