Schannel: check that plainsocket is open before use
In reality I think it should be covered elsewhere, before reaching the TLS code. But this is a simple fix to avoid an unnecessary warning. This is actually quite similar to the resolution in ef4ba0285f9c5dd5ee2dca1e0cefee45eba3477c. Technically checking isWritable would be more correct, but Qt is usually the one to open the socket, and we open for both read and write anyway. Fixes: QTBUG-116550 Change-Id: I4996b18b5b65c434d91543451186f335e201604f Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 74f16c0ed5f0e0bb05e8a9b40266524cec8e4257) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 4d3a69cea3f3d91657d33968c904b2d68f69d978) (cherry picked from commit e9c7f3207c634864efe893e8d31077fc05cc61e2)
This commit is contained in:
parent
c9354149fa
commit
8e2e4cc0e0
@ -722,8 +722,10 @@ bool TlsCryptographSchannel::sendToken(void *token, unsigned long tokenLength, b
|
|||||||
Q_ASSERT(d);
|
Q_ASSERT(d);
|
||||||
auto *plainSocket = d->plainTcpSocket();
|
auto *plainSocket = d->plainTcpSocket();
|
||||||
Q_ASSERT(plainSocket);
|
Q_ASSERT(plainSocket);
|
||||||
if (plainSocket->state() == QAbstractSocket::UnconnectedState || !plainSocket->isValid())
|
if (plainSocket->state() == QAbstractSocket::UnconnectedState || !plainSocket->isValid()
|
||||||
|
|| !plainSocket->isOpen()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const qint64 written = plainSocket->write(static_cast<const char *>(token), tokenLength);
|
const qint64 written = plainSocket->write(static_cast<const char *>(token), tokenLength);
|
||||||
if (written != qint64(tokenLength)) {
|
if (written != qint64(tokenLength)) {
|
||||||
@ -1118,7 +1120,8 @@ bool TlsCryptographSchannel::performHandshake()
|
|||||||
auto *plainSocket = d->plainTcpSocket();
|
auto *plainSocket = d->plainTcpSocket();
|
||||||
Q_ASSERT(plainSocket);
|
Q_ASSERT(plainSocket);
|
||||||
|
|
||||||
if (plainSocket->state() == QAbstractSocket::UnconnectedState || !plainSocket->isValid()) {
|
if (plainSocket->state() == QAbstractSocket::UnconnectedState || !plainSocket->isValid()
|
||||||
|
|| !plainSocket->isOpen()) {
|
||||||
setErrorAndEmit(d, QAbstractSocket::RemoteHostClosedError,
|
setErrorAndEmit(d, QAbstractSocket::RemoteHostClosedError,
|
||||||
QSslSocket::tr("The TLS/SSL connection has been closed"));
|
QSslSocket::tr("The TLS/SSL connection has been closed"));
|
||||||
return false;
|
return false;
|
||||||
@ -1488,8 +1491,10 @@ void TlsCryptographSchannel::transmit()
|
|||||||
return; // This function should not have been called
|
return; // This function should not have been called
|
||||||
|
|
||||||
// Can happen if called through QSslSocket::abort->QSslSocket::close->QSslSocket::flush->here
|
// Can happen if called through QSslSocket::abort->QSslSocket::close->QSslSocket::flush->here
|
||||||
if (plainSocket->state() == QAbstractSocket::UnconnectedState || !plainSocket->isValid())
|
if (plainSocket->state() == QAbstractSocket::UnconnectedState || !plainSocket->isValid()
|
||||||
|
|| !plainSocket->isOpen()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (schannelState != SchannelState::Done) {
|
if (schannelState != SchannelState::Done) {
|
||||||
continueHandshake();
|
continueHandshake();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user