summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qlocalserver_unix.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2015-10-02 15:04:15 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2015-10-02 17:24:58 +0000
commit925d6eff3e8e5bc801210a67ec4cf1d4b3492fc2 (patch)
treea03f381e4823e29b2e50c1a80588f06e450656fc /src/network/socket/qlocalserver_unix.cpp
parenta3292031295a09e5e959141db78c2310e08562ae (diff)
parentd0eaa737e10aed34c09ba753e21c3e027b5ce58c (diff)
Merge "Merge remote-tracking branch 'origin/5.5' into 5.6" into refs/staging/5.6
Diffstat (limited to 'src/network/socket/qlocalserver_unix.cpp')
-rw-r--r--src/network/socket/qlocalserver_unix.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/network/socket/qlocalserver_unix.cpp b/src/network/socket/qlocalserver_unix.cpp
index ef10b1e68d..634074d91f 100644
--- a/src/network/socket/qlocalserver_unix.cpp
+++ b/src/network/socket/qlocalserver_unix.cpp
@@ -85,7 +85,8 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
}
serverName = requestedServerName;
- QString tempPath;
+ QByteArray encodedTempPath;
+ const QByteArray encodedFullServerName = QFile::encodeName(fullServerName);
QScopedPointer<QTemporaryDir> tempDir;
// Check any of the flags
@@ -96,8 +97,7 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
setError(QLatin1String("QLocalServer::listen"));
return false;
}
- tempPath = tempDir->path();
- tempPath += QLatin1String("/s");
+ encodedTempPath = QFile::encodeName(tempDir->path() + QLatin1String("/s"));
}
// create the unix socket
@@ -111,23 +111,23 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
// Construct the unix address
struct ::sockaddr_un addr;
addr.sun_family = PF_UNIX;
- if (sizeof(addr.sun_path) < (uint)fullServerName.toLatin1().size() + 1) {
+ if (sizeof(addr.sun_path) < (uint)encodedFullServerName.size() + 1) {
setError(QLatin1String("QLocalServer::listen"));
closeServer();
return false;
}
if (socketOptions & QLocalServer::WorldAccessOption) {
- if (sizeof(addr.sun_path) < (uint)tempPath.toLatin1().size() + 1) {
+ if (sizeof(addr.sun_path) < (uint)encodedTempPath.size() + 1) {
setError(QLatin1String("QLocalServer::listen"));
closeServer();
return false;
}
- ::memcpy(addr.sun_path, tempPath.toLatin1().data(),
- tempPath.toLatin1().size() + 1);
+ ::memcpy(addr.sun_path, encodedTempPath.constData(),
+ encodedTempPath.size() + 1);
} else {
- ::memcpy(addr.sun_path, fullServerName.toLatin1().data(),
- fullServerName.toLatin1().size() + 1);
+ ::memcpy(addr.sun_path, encodedFullServerName.constData(),
+ encodedFullServerName.size() + 1);
}
// bind
@@ -165,13 +165,13 @@ bool QLocalServerPrivate::listen(const QString &requestedServerName)
if (socketOptions & QLocalServer::OtherAccessOption)
mode |= S_IRWXO;
- if (::chmod(tempPath.toLatin1(), mode) == -1) {
+ if (::chmod(encodedTempPath.constData(), mode) == -1) {
setError(QLatin1String("QLocalServer::listen"));
closeServer();
return false;
}
- if (::rename(tempPath.toLatin1(), fullServerName.toLatin1()) == -1) {
+ if (::rename(encodedTempPath.constData(), encodedFullServerName.constData()) == -1) {
setError(QLatin1String("QLocalServer::listen"));
closeServer();
return false;