summaryrefslogtreecommitdiff
path: root/net-libs/signon-oauth2/files/0004-Port-away-from-deprecated-qrand.patch
blob: ef78049953465fe143835180a9a76460998131c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
From 039dab8db2e16d02872c6e12c698157e05dc43e2 Mon Sep 17 00:00:00 2001
From: Nicolas Fella <nicolas.fella@gmx.de>
Date: Sun, 15 Oct 2023 19:02:04 +0200
Subject: [PATCH 04/10] Port away from deprecated qrand

---
 src/oauth1plugin.cpp | 7 +++++++
 src/oauth2plugin.cpp | 6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/src/oauth1plugin.cpp b/src/oauth1plugin.cpp
index 8ec7645..6c38cbb 100644
--- a/src/oauth1plugin.cpp
+++ b/src/oauth1plugin.cpp
@@ -94,8 +94,10 @@ public:
     {
         TRACE();
 
+#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
         // Initialize randomizer
         qsrand(QTime::currentTime().msec());
+#endif
     }
 
     ~OAuth1PluginPrivate()
@@ -437,8 +439,13 @@ QString OAuth1Plugin::createOAuth1Header(const QString &aUrl,
                       .arg(urlEncode(inData.ConsumerKey())));
     authHeader.append(DELIMITER);
     // Nonce
+#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
     unsigned long nonce1 = (unsigned long) qrand();
     unsigned long nonce2 = (unsigned long) qrand();
+#else
+    unsigned long nonce1 = QRandomGenerator::global()->generate64();
+    unsigned long nonce2 = QRandomGenerator::global()->generate64();
+#endif
     QString oauthNonce = QString("%1%2").arg(nonce1).arg(nonce2);
     authHeader.append(EQUAL_WITH_QUOTES.arg(OAUTH_NONCE)
                       .arg(urlEncode(oauthNonce)));
diff --git a/src/oauth2plugin.cpp b/src/oauth2plugin.cpp
index 418e7db..8763f00 100644
--- a/src/oauth2plugin.cpp
+++ b/src/oauth2plugin.cpp
@@ -84,8 +84,10 @@ public:
     {
         TRACE();
 
+#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
         // Initialize randomizer
         qsrand(QTime::currentTime().msec());
+#endif
     }
 
     ~OAuth2PluginPrivate()
@@ -180,7 +182,11 @@ void OAuth2Plugin::sendOAuth2AuthRequest()
     QString redirectUri = d->m_oauth2Data.RedirectUri();
     query.addQueryItem(REDIRECT_URI, QUrl::toPercentEncoding(redirectUri));
     if (!d->m_oauth2Data.DisableStateParameter()) {
+#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
         d->m_state = QString::number(qrand());
+#else
+        d->m_state = QString::number(QRandomGenerator::global()->generate());
+#endif
         query.addQueryItem(STATE, d->m_state);
     }
     QStringList responseType = d->m_oauth2Data.ResponseType();
-- 
2.43.0