mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
[Servatrice] Fix silently broken socket error connections (#7626)
* [Servatrice] Fix silently broken socket error connections QAbstractSocket::error() was removed in Qt 6 in favour of errorOccurred(). The ISL interface connected to the old name through SIGNAL(), which compiles but fails at runtime, so catchSocketError never ran. The WebSocket interface used the same name on QWebSocket, where it still exists but is deprecated since 6.5. Use errorOccurred for both. The WebSocket connect needs a lambda because catchSocketError is a protected base-class slot and a base pointer-to-member is not accessible from the derived class. * [Servatrice] Guard the WebSocket error connect against Qt 6.4 QWebSocket gained errorOccurred in 6.5 and dropped the error signal with it, so the typed connect cannot compile against the 6.4 floor that Debian 12 and Ubuntu 24.04 still use. Keep the typed connect on 6.5+ and fall back to the old-style connect below it, which is what the code did before. Verified both branches compile: forcing the guard to the else path and rebuilding serversocketinterface.cpp succeeds, so the 6.4 spelling is intact. * [Servatrice] Initialize ISL serverId before authentication catchSocketError() removes islInterfaces[serverId], but the incoming connection constructor left serverId uninitialized until initServer() set it after the SSL handshake and certificate check. A socket error during waitForEncrypted() therefore read an indeterminate key. * [Servatrice] Correct the QWebSocket error signal note error() was deprecated in 6.5, not removed; errorOccurred() was added in 6.5. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
825aba953a
commit
344dbd2caa
2 changed files with 9 additions and 3 deletions
|
|
@ -59,8 +59,7 @@ void IslInterface::sharedCtor(const QSslCertificate &cert, const QSslKey &privat
|
||||||
socket->setPrivateKey(privateKey);
|
socket->setPrivateKey(privateKey);
|
||||||
|
|
||||||
connect(socket, SIGNAL(readyRead()), this, SLOT(readClient()), Qt::QueuedConnection);
|
connect(socket, SIGNAL(readyRead()), this, SLOT(readClient()), Qt::QueuedConnection);
|
||||||
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this,
|
connect(socket, &QAbstractSocket::errorOccurred, this, &IslInterface::catchSocketError);
|
||||||
SLOT(catchSocketError(QAbstractSocket::SocketError)));
|
|
||||||
connect(this, SIGNAL(outputBufferChanged()), this, SLOT(flushOutputBuffer()), Qt::QueuedConnection);
|
connect(this, SIGNAL(outputBufferChanged()), this, SLOT(flushOutputBuffer()), Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,7 +67,7 @@ IslInterface::IslInterface(int _socketDescriptor,
|
||||||
const QSslCertificate &cert,
|
const QSslCertificate &cert,
|
||||||
const QSslKey &privateKey,
|
const QSslKey &privateKey,
|
||||||
Servatrice *_server)
|
Servatrice *_server)
|
||||||
: QObject(), socketDescriptor(_socketDescriptor), server(_server), messageInProgress(false)
|
: QObject(), serverId(-1), socketDescriptor(_socketDescriptor), server(_server), messageInProgress(false)
|
||||||
{
|
{
|
||||||
sharedCtor(cert, privateKey);
|
sharedCtor(cert, privateKey);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4651,8 +4651,15 @@ void WebsocketServerSocketInterface::initConnection(void *_socket)
|
||||||
|
|
||||||
connect(socket, SIGNAL(binaryMessageReceived(const QByteArray &)), this,
|
connect(socket, SIGNAL(binaryMessageReceived(const QByteArray &)), this,
|
||||||
SLOT(binaryMessageReceived(const QByteArray &)));
|
SLOT(binaryMessageReceived(const QByteArray &)));
|
||||||
|
// QWebSocket::errorOccurred was added in Qt 6.5 (error() is deprecated from 6.5 on),
|
||||||
|
// so a typed connect cannot compile against the 6.4 floor.
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||||
|
connect(socket, &QWebSocket::errorOccurred, this,
|
||||||
|
[this](QAbstractSocket::SocketError error) { catchSocketError(error); });
|
||||||
|
#else
|
||||||
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this,
|
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this,
|
||||||
SLOT(catchSocketError(QAbstractSocket::SocketError)));
|
SLOT(catchSocketError(QAbstractSocket::SocketError)));
|
||||||
|
#endif
|
||||||
connect(socket, SIGNAL(disconnected()), this, SLOT(catchSocketDisconnected()));
|
connect(socket, SIGNAL(disconnected()), this, SLOT(catchSocketDisconnected()));
|
||||||
|
|
||||||
// Add this object to the server's list of connections before it can receive socket events.
|
// Add this object to the server's list of connections before it can receive socket events.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue