summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2020-06-10 13:56:34 +0200
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2020-06-10 22:55:49 +0200
commit7d989648151c577c1706ca85acf70edca4b91363 (patch)
treeb145717e6c0e632d348450390fef71e784fc3432 /tests/auto
parentad532ce118b7052be3b69999cef2eb610e66fa88 (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. Pick-to: 5.15 Change-Id: Ia10ae18a40b5b8f006c45147b06fe5be6efcb129 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp13
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 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 <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>
@@ -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<quint32 *>(data.data()),
+ data.size() / int(sizeof(quint32)));
if (!socket->waitForEncrypted(10000))
QSKIP("Skipping flaky test - See QTBUG-29941");