Package: asterisk / 1:13.14.1~dfsg-2+deb9u4

859911-pjsip-set-rtp-source-address-part2.patch Patch series | download
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
From 2634f48fb57e1358ad1de0683e9779cc05efe2c4 Mon Sep 17 00:00:00 2001
From: Richard Mudgett <rmudgett@digium.com>
Date: Mon, 3 Apr 2017 15:38:06 -0500
Subject: [PATCH] res_pjsip_sdp_rtp.c: Don't alter global addr variable.

* create_rtp(): Fix unexpected alteration of global address_rtp if a
transport is bound to an address.

* create_rtp(): Fix use of uninitialized memory if the endpoint RTP media
address is invalid or the transport has an invalid address.

ASTERISK-26851

Change-Id: Icde42e65164a88913cb5c2601b285eebcff397b7
---
 res/res_pjsip_sdp_rtp.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c
index d44171cf8f..4cfd4d5b4a 100644
--- a/res/res_pjsip_sdp_rtp.c
+++ b/res/res_pjsip_sdp_rtp.c
@@ -194,8 +194,16 @@ static int create_rtp(struct ast_sip_session *session, struct ast_sip_session_me
 	struct ast_sockaddr *media_address =  &address_rtp;
 
 	if (session->endpoint->media.bind_rtp_to_media_address && !ast_strlen_zero(session->endpoint->media.address)) {
-		ast_sockaddr_parse(&temp_media_address, session->endpoint->media.address, 0);
-		media_address = &temp_media_address;
+		if (ast_sockaddr_parse(&temp_media_address, session->endpoint->media.address, 0)) {
+			ast_debug(1, "Endpoint %s: Binding RTP media to %s\n",
+				ast_sorcery_object_get_id(session->endpoint),
+				session->endpoint->media.address);
+			media_address = &temp_media_address;
+		} else {
+			ast_debug(1, "Endpoint %s: RTP media address invalid: %s\n",
+				ast_sorcery_object_get_id(session->endpoint),
+				session->endpoint->media.address);
+		}
 	} else {
 		struct ast_sip_transport *transport =
 			ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport",
@@ -205,9 +213,14 @@ static int create_rtp(struct ast_sip_session *session, struct ast_sip_session_me
 			char hoststr[PJ_INET6_ADDRSTRLEN];
 
 			pj_sockaddr_print(&transport->state->host, hoststr, sizeof(hoststr), 0);
-			ast_debug(1, "Transport: %s bound to host: %s, using this for media.\n",
-					  session->endpoint->transport, hoststr);
-			ast_sockaddr_parse(media_address, hoststr, 0);
+			if (ast_sockaddr_parse(&temp_media_address, hoststr, 0)) {
+				ast_debug(1, "Transport %s bound to %s: Using it for RTP media.\n",
+					session->endpoint->transport, hoststr);
+				media_address = &temp_media_address;
+			} else {
+				ast_debug(1, "Transport %s bound to %s: Invalid for RTP media.\n",
+					session->endpoint->transport, hoststr);
+			}
 		}
 		ao2_cleanup(transport);
 	}
-- 
2.11.0