Check we're connected before startClientEncryption()
The docs say this is required, but we don't check it and instead segfault right now. Change-Id: I825b00a312a481c5383af127333c0c4698188348 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Peter Hartmann <peter.hartmann@nokia.com>
This commit is contained in:
parent
47df122259
commit
2757a5fe8c
@ -1630,6 +1630,10 @@ void QSslSocket::startClientEncryption()
|
|||||||
qWarning("QSslSocket::startClientEncryption: cannot start handshake on non-plain connection");
|
qWarning("QSslSocket::startClientEncryption: cannot start handshake on non-plain connection");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (state() != ConnectedState) {
|
||||||
|
qWarning("QSslSocket::startClientEncryption: cannot start handshake when not connected");
|
||||||
|
return;
|
||||||
|
}
|
||||||
#ifdef QSSLSOCKET_DEBUG
|
#ifdef QSSLSOCKET_DEBUG
|
||||||
qDebug() << "QSslSocket::startClientEncryption()";
|
qDebug() << "QSslSocket::startClientEncryption()";
|
||||||
#endif
|
#endif
|
||||||
|
@ -195,6 +195,7 @@ private slots:
|
|||||||
void setEmptyDefaultConfiguration();
|
void setEmptyDefaultConfiguration();
|
||||||
void versionAccessors();
|
void versionAccessors();
|
||||||
void sslOptions();
|
void sslOptions();
|
||||||
|
void encryptWithoutConnecting();
|
||||||
|
|
||||||
static void exitLoop()
|
static void exitLoop()
|
||||||
{
|
{
|
||||||
@ -2122,6 +2123,18 @@ void tst_QSslSocket::sslOptions()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QSslSocket::encryptWithoutConnecting()
|
||||||
|
{
|
||||||
|
if (!QSslSocket::supportsSsl())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QTest::ignoreMessage(QtWarningMsg,
|
||||||
|
"QSslSocket::startClientEncryption: cannot start handshake when not connected");
|
||||||
|
|
||||||
|
QSslSocket sock;
|
||||||
|
sock.startClientEncryption();
|
||||||
|
}
|
||||||
|
|
||||||
#endif // QT_NO_OPENSSL
|
#endif // QT_NO_OPENSSL
|
||||||
|
|
||||||
QTEST_MAIN(tst_QSslSocket)
|
QTEST_MAIN(tst_QSslSocket)
|
||||||
|
Loading…
Reference in New Issue
Block a user