From 7d989648151c577c1706ca85acf70edca4b91363 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 10 Jun 2020 13:56:34 +0200 Subject: tst_QSslSocket - stop using qrand (to suppress a warning) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Pick-to: 5.15 Change-Id: Ia10ae18a40b5b8f006c45147b06fe5be6efcb129 Reviewed-by: MÃ¥rten Nordheim --- tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 28a819414d..ded9c722d3 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -2627,13 +2628,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(data.data()), + data.size() / int(sizeof(quint32))); if (!socket->waitForEncrypted(10000)) QSKIP("Skipping flaky test - See QTBUG-29941"); -- cgit v1.2.3