Commit 5a9a3e96 authored by Xuetian Weng's avatar Xuetian Weng Committed by Vlad Zahorodnii
Browse files

Fix XWayland abstract socket address.

NUL-termination byte is not needed for abstract socket. This leads to
XWayland listening to a wrong address.

Confirmed with lsof.

BUG: 442362


(cherry picked from commit 83a036e9)
parent cdb6999e
......@@ -42,19 +42,18 @@ UnixSocketAddress::UnixSocketAddress(const QString &socketPath, Type type)
const QByteArray encodedSocketPath = QFile::encodeName(socketPath);
int byteCount = offsetof(sockaddr_un, sun_path) + encodedSocketPath.size() + 1;
if (type == Type::Abstract) {
byteCount++; // For the first '\0'.
}
m_buffer.resize(byteCount);
sockaddr_un *address = reinterpret_cast<sockaddr_un *>(m_buffer.data());
address->sun_family = AF_UNIX;
if (type == Type::Unix) {
qstrcpy(address->sun_path, encodedSocketPath);
memcpy(address->sun_path, encodedSocketPath.data(), encodedSocketPath.size());
address->sun_path[encodedSocketPath.size()] = '\0';
} else {
// Abstract domain socket does not need the NUL-termination byte.
*address->sun_path = '\0';
qstrcpy(address->sun_path + 1, encodedSocketPath);
memcpy(address->sun_path + 1, encodedSocketPath.data(), encodedSocketPath.size());
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment