File: 0019-plugins-airplay-build-against-openssl-1.1.0.patch

package info (click to toggle)
xmms2 0.8%2Bdfsg-29
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,216 kB
  • sloc: ansic: 63,803; python: 15,537; cpp: 5,718; xml: 1,479; perl: 338; ruby: 243; makefile: 79; sh: 59; asm: 7
file content (59 lines) | stat: -rw-r--r-- 1,600 bytes parent folder | download | duplicates (5)
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
From: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Date: Tue, 30 Aug 2016 19:01:11 +0000
Subject: plugins/airplay: build against openssl 1.1.0

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
---
 src/plugins/airplay/raop_client.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/plugins/airplay/raop_client.c b/src/plugins/airplay/raop_client.c
index 17097e0..5310f6f 100644
--- a/src/plugins/airplay/raop_client.c
+++ b/src/plugins/airplay/raop_client.c
@@ -135,15 +135,34 @@ raop_rsa_encrypt (guchar *text, gint len, guchar *res)
 		0x5e,0xf,0xc8,0x75,0x34,0x3e,0xc7,0x82,0x11,0x76,0x25,0xcd
 		,0xbf,0x98,0x44,0x7b};
 	static const guchar exp[] = {0x01, 0x00, 0x01};
+	BIGNUM *n, *e;
 
 	rsa = RSA_new ();
-	rsa->n = BN_bin2bn (mod, 256, NULL);
-	rsa->e = BN_bin2bn (exp, 3, NULL);
+	n = BN_bin2bn (mod, 256, NULL);
+	e = BN_bin2bn (exp, 3, NULL);
+	if (!rsa || !n || !e)
+		goto err;
+
+#if OPENSSL_VERSION_NUMBER < 0x10100000
+	rsa->n = n;
+	rsa->e = e;
+#else
+	if (!RSA_set0_key(rsa, n, e, NULL))
+		goto err;
+#endif
 
 	size = RSA_public_encrypt (len, text, res, rsa, RSA_PKCS1_OAEP_PADDING);
 
 	RSA_free (rsa);
 	return size;
+err:
+	if (rsa)
+		RSA_free(rsa);
+	if (n)
+		BN_free(n);
+	if (e)
+		BN_free(e);
+	return 0;
 }
 
 static void
@@ -250,6 +269,8 @@ raop_rtsp_announce (raop_client_t *rc)
 	gint ret = RAOP_EOK;
 
 	size = raop_rsa_encrypt (rc->aes_key_str, 16, enc_aes_key);
+	if (size == 0)
+		return RAOP_EFAIL;
 
 	size = b64_encode_alloc (enc_aes_key, size, &key);
 	g_strdelimit (key, "=", '\0');