Merge pull request #10497 from aleksander0m/aleksander/mm-ipv6
[feed/packages.git] / libs / spice / patches / 0002-reds-Fix-compilation-without-deprecated-OpenSSL-1.1-.patch
1 From 5bc932f7a71ede7d8ecd9d88804af95a2eb955c0 Mon Sep 17 00:00:00 2001
2 From: Rosen Penev <rosenp@gmail.com>
3 Date: Sun, 3 Nov 2019 15:34:33 -0800
4 Subject: [PATCH] reds: Fix compilation without deprecated OpenSSL 1.1 APIs
5
6 Missing headers for BN_ and RSA_ functions.
7
8 Initialization is deprecated with 1.1.
9
10 Signed-off-by: Rosen Penev <rosenp@gmail.com>
11 Acked-by: Frediano Ziglio <fziglio@redhat.com>
12 ---
13 AUTHORS hunk removed as it does not apply (with 0.14.2 at least)
14
15 AUTHORS | 1 +
16 server/reds.c | 24 ++++++++++++++++--------
17 2 files changed, 17 insertions(+), 8 deletions(-)
18
19 diff --git a/server/reds.c b/server/reds.c
20 index c55aa3f8..dc03ef3a 100644
21 --- a/server/reds.c
22 +++ b/server/reds.c
23 @@ -36,7 +36,9 @@
24 #include <ws2tcpip.h>
25 #endif
26
27 +#include <openssl/bn.h>
28 #include <openssl/err.h>
29 +#include <openssl/rsa.h>
30
31 #if HAVE_SASL
32 #include <sasl/sasl.h>
33 @@ -2838,13 +2840,8 @@ static void openssl_thread_setup(void)
34 CRYPTO_set_id_callback(pthreads_thread_id);
35 CRYPTO_set_locking_callback(pthreads_locking_callback);
36 }
37 -#else
38 -static inline void openssl_thread_setup(void)
39 -{
40 -}
41 -#endif
42
43 -static gpointer openssl_global_init(gpointer arg)
44 +static gpointer openssl_global_init_once(gpointer arg)
45 {
46 SSL_library_init();
47 SSL_load_error_strings();
48 @@ -2854,9 +2851,20 @@ static gpointer openssl_global_init(gpointer arg)
49 return NULL;
50 }
51
52 -static int reds_init_ssl(RedsState *reds)
53 +static inline void openssl_global_init(void)
54 {
55 static GOnce openssl_once = G_ONCE_INIT;
56 + g_once(&openssl_once, openssl_global_init_once, NULL);
57 +}
58 +
59 +#else
60 +static inline void openssl_global_init(void)
61 +{
62 +}
63 +#endif
64 +
65 +static int reds_init_ssl(RedsState *reds)
66 +{
67 const SSL_METHOD *ssl_method;
68 int return_code;
69 /* Limit connection to TLSv1.1 or newer.
70 @@ -2865,7 +2873,7 @@ static int reds_init_ssl(RedsState *reds)
71 long ssl_options = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION | SSL_OP_NO_TLSv1;
72
73 /* Global system initialization*/
74 - g_once(&openssl_once, openssl_global_init, NULL);
75 + openssl_global_init();
76
77 /* Create our context*/
78 /* SSLv23_method() handles TLSv1.x in addition to SSLv2/v3 */