From 320360131559df76ba1f635b665659f57e147665 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Tue, 28 Oct 2014 13:53:14 +0200 Subject: [PATCH] Fix QLocalServer, create a temp path as small as possible. If requestedServerName is a full path e.g. "/tmp/some/long/path" the temp path will end up "/tmp/some/long/path.balblabla/tmp/some/long/path" and it might fail because it doesn't fit in addr.sun_path. Change-Id: I6a138fd92be9e0b3b432ab9ac977d04cb330f3fd Reviewed-by: Oswald Buddenhagen --- src/network/socket/qlocalserver_unix.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/network/socket/qlocalserver_unix.cpp b/src/network/socket/qlocalserver_unix.cpp index 313fe4ad29..a615dcc7b6 100644 --- a/src/network/socket/qlocalserver_unix.cpp +++ b/src/network/socket/qlocalserver_unix.cpp @@ -90,13 +90,14 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName) // Check any of the flags if (socketOptions & QLocalServer::WorldAccessOption) { - tempDir.reset(new QTemporaryDir(fullServerName)); + QFileInfo serverNameFileInfo(fullServerName); + tempDir.reset(new QTemporaryDir(serverNameFileInfo.absolutePath() + QLatin1Char('/'))); if (!tempDir->isValid()) { setError(QLatin1String("QLocalServer::listen")); return false; } tempPath = tempDir->path(); - tempPath += QLatin1Char('/') + requestedServerName; + tempPath += QLatin1String("/s"); } // create the unix socket