Description: openssl3 SSL_CTX_set_options signature update
 openssl3 changed the options parameter of SSL_CTX_set_options from long
 to uint64_t. This breaks compatibility with platforms where sizeof(long)!=sizeof(uint64_t)

Author: Michael Saxl <saxl@brennercom.net>
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1981807

--- qtbase-opensource-src-5.15.3+dfsg.orig/src/network/ssl/qsslcontext_openssl.cpp
+++ qtbase-opensource-src-5.15.3+dfsg/src/network/ssl/qsslcontext_openssl.cpp
@@ -455,7 +455,7 @@ init_context:
     }
 
     // Enable bug workarounds.
-    long options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
+    uint64_t options = QSslSocketBackendPrivate::setupOpenSslOptions(configuration.protocol(), configuration.d->sslOptions);
     q_SSL_CTX_set_options(sslContext->ctx, options);
 
     // Tell OpenSSL to release memory early
--- qtbase-opensource-src-5.15.3+dfsg.orig/src/network/ssl/qsslsocket_openssl.cpp
+++ qtbase-opensource-src-5.15.3+dfsg/src/network/ssl/qsslsocket_openssl.cpp
@@ -528,9 +528,9 @@ static void q_loadCiphersForConnection(S
 // Defined in qsslsocket.cpp
 void q_setDefaultDtlsCiphers(const QList<QSslCipher> &ciphers);
 
-long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
+uint64_t QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
 {
-    long options;
+    uint64_t options;
     if (protocol == QSsl::TlsV1SslV3)
         options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
     else if (protocol == QSsl::SecureProtocols)
--- qtbase-opensource-src-5.15.3+dfsg.orig/src/network/ssl/qsslsocket_openssl_p.h
+++ qtbase-opensource-src-5.15.3+dfsg/src/network/ssl/qsslsocket_openssl_p.h
@@ -164,7 +164,7 @@ public:
     QVector<QSslError> ocspErrors;
     QByteArray ocspResponseDer;
 
-    Q_AUTOTEST_EXPORT static long setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
+    Q_AUTOTEST_EXPORT static uint64_t setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions);
     static QSslCipher QSslCipher_from_SSL_CIPHER(const SSL_CIPHER *cipher);
     static QList<QSslCertificate> STACKOFX509_to_QSslCertificates(STACK_OF(X509) *x509);
     static QList<QSslError> verify(const QList<QSslCertificate> &certificateChain, const QString &hostName);
--- qtbase-opensource-src-5.15.3+dfsg.orig/src/network/ssl/qsslsocket_openssl_symbols.cpp
+++ qtbase-opensource-src-5.15.3+dfsg/src/network/ssl/qsslsocket_openssl_symbols.cpp
@@ -157,7 +157,11 @@ DEFINEFUNC2(void, OPENSSL_sk_push, OPENS
 DEFINEFUNC(void, OPENSSL_sk_free, OPENSSL_STACK *a, a, return, DUMMYARG)
 DEFINEFUNC2(void *, OPENSSL_sk_value, OPENSSL_STACK *a, a, int b, b, return nullptr, return)
 DEFINEFUNC(int, SSL_session_reused, SSL *a, a, return 0, return)
-DEFINEFUNC2(unsigned long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, unsigned long op, op, return 0, return)
+#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
+DEFINEFUNC2(uint64_t, SSL_CTX_set_options, SSL_CTX *ctx, ctx, uint64_t op, op, return 0, return)
+#else
+DEFINEFUNC2(long, SSL_CTX_set_options, SSL_CTX *ctx, ctx, long op, op, return 0, return)
+#endif
 DEFINEFUNC(int, SSL_CTX_get_security_level, const SSL_CTX *ctx, ctx, return -1, return)
 DEFINEFUNC2(void, SSL_CTX_set_security_level, SSL_CTX *ctx, ctx, int level, level, return, return)
 #ifdef TLS1_3_VERSION
--- qtbase-opensource-src-5.15.3+dfsg.orig/src/network/ssl/qsslsocket_openssl_symbols_p.h
+++ qtbase-opensource-src-5.15.3+dfsg/src/network/ssl/qsslsocket_openssl_symbols_p.h
@@ -244,7 +244,11 @@ Q_AUTOTEST_EXPORT void q_OPENSSL_sk_push
 Q_AUTOTEST_EXPORT void q_OPENSSL_sk_free(OPENSSL_STACK *a);
 Q_AUTOTEST_EXPORT void * q_OPENSSL_sk_value(OPENSSL_STACK *a, int b);
 int q_SSL_session_reused(SSL *a);
-unsigned long q_SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op);
+#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
+uint64_t q_SSL_CTX_set_options(SSL_CTX *ctx, uint64_t op);
+#else
+long q_SSL_CTX_set_options(SSL_CTX *ctx, long op);
+#endif
 int q_OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings);
 size_t q_SSL_get_client_random(SSL *a, unsigned char *out, size_t outlen);
 size_t q_SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *out, size_t outlen);
