diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2020-06-10 13:56:34 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-06-10 23:28:37 +0000 |
commit | 1f004f63fe160e863ea6183d48dde78b4d27f0f4 (patch) | |
tree | d905d46e3f3d33d16818052097c94d47e7a7c4b7 /tests/auto/network/ssl/qsslsocket | |
parent | 777f2a1c1e7e1cd669cc152aaa5b99d68b8a1ccd (diff) |
tst_QSslSocket - stop using qrand (to suppress a warning)
Whoever wrote this test, was a PROPER hacker: trying to force a TLS implementation
not to properly compress some data, they generated a sequence of bytes in a very fancy manner,
something like 255 0 0 0 255 0 0 0 123 0 0 0 255 0 0 0 - yeah, it's really a random sequence
of bytes, surely, it's impossible to compress! Meh.
Change-Id: Ia10ae18a40b5b8f006c45147b06fe5be6efcb129
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 7d989648151c577c1706ca85acf70edca4b91363)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests/auto/network/ssl/qsslsocket')
-rw-r--r-- | tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index b22c929897..e5a6073b1d 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -30,6 +30,7 @@ #include <QtCore/qglobal.h> #include <QtCore/qthread.h> #include <QtCore/qelapsedtimer.h> +#include <QtCore/qrandom.h> #include <QtNetwork/qhostaddress.h> #include <QtNetwork/qhostinfo.h> #include <QtNetwork/qnetworkproxy.h> @@ -2674,13 +2675,11 @@ void tst_QSslSocket::writeBigChunk() socket->connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443); QByteArray data; - data.resize(1024*1024*10); // 10 MB - // init with garbage. needed so ssl cannot compress it in an efficient way. - // ### Qt 6: update to a random engine - for (size_t i = 0; i < data.size() / sizeof(int); i++) { - int r = qrand(); - data.data()[i*sizeof(int)] = r; - } + // Originally, the test had this: '1024*1024*10; // 10 MB' + data.resize(1024 * 1024 * 10); + // Init with garbage. Needed so TLS cannot compress it in an efficient way. + QRandomGenerator::global()->fillRange(reinterpret_cast<quint32 *>(data.data()), + data.size() / int(sizeof(quint32))); if (!socket->waitForEncrypted(10000)) QSKIP("Skipping flaky test - See QTBUG-29941"); |