[asterisk-commits] kmoore: branch kmoore/pjsip_dtls r394604 - /team/kmoore/pjsip_dtls/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 17 14:52:20 CDT 2013


Author: kmoore
Date: Wed Jul 17 14:52:18 2013
New Revision: 394604

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=394604
Log:
Fix bugs in chan_sip regarding DTLS

A new check in chan_sip to prevent acceptance of SRTP streams without
crypto information wasn't taking DTLS into account.

Fix a segfault that can occur when DTLS is enabled.

Modified:
    team/kmoore/pjsip_dtls/channels/chan_sip.c

Modified: team/kmoore/pjsip_dtls/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_dtls/channels/chan_sip.c?view=diff&rev=394604&r1=394603&r2=394604
==============================================================================
--- team/kmoore/pjsip_dtls/channels/chan_sip.c (original)
+++ team/kmoore/pjsip_dtls/channels/chan_sip.c Wed Jul 17 14:52:18 2013
@@ -10194,6 +10194,7 @@
 				} else if (!strcmp(protocol, "UDP/TLS/RTP/SAVP") || !strcmp(protocol, "UDP/TLS/RTP/SAVPF")) {
 					secure_audio = 1;
 
+					processed_crypto = 1;
 					if (p->srtp) {
 						ast_set_flag(p->srtp, AST_SRTP_CRYPTO_OFFER_OK);
 					}
@@ -10276,6 +10277,7 @@
 				} else if (!strcmp(protocol, "UDP/TLS/RTP/SAVP") || !strcmp(protocol, "UDP/TLS/RTP/SAVPF")) {
 					secure_video = 1;
 
+					processed_crypto = 1;
 					if (p->vsrtp || (p->vsrtp = ast_sdp_srtp_alloc())) {
 						ast_set_flag(p->vsrtp, AST_SRTP_CRYPTO_OFFER_OK);
 					}
@@ -13037,13 +13039,17 @@
 static char *crypto_get_attrib(struct ast_sdp_srtp *srtp, int dtls_enabled, int default_taglen_32)
 {
 	char *a_crypto;
-	char *orig_crypto;
-
-	if (!srtp) {
+	const char *orig_crypto;
+
+	if (!srtp || dtls_enabled) {
 		return NULL;
 	}
 
-	orig_crypto = ast_strdupa(ast_sdp_srtp_get_attrib(srtp, dtls_enabled, default_taglen_32));
+	orig_crypto = ast_sdp_srtp_get_attrib(srtp, dtls_enabled, default_taglen_32);
+	if (ast_strlen_zero(orig_crypto)) {
+		return NULL;
+	}
+
 	if (ast_asprintf(&a_crypto, "a=crypto:%s\r\n", orig_crypto) == -1) {
 		return NULL;
 	}
@@ -13211,7 +13217,7 @@
 			v_a_crypto = crypto_get_attrib(p->vsrtp, p->dtls_cfg.enabled,
 				ast_test_flag(&p->flags[2], SIP_PAGE3_SRTP_TAG_32));
 			ast_str_append(&m_video, 0, "m=video %d %s", ast_sockaddr_port(&vdest),
-				ast_sdp_get_rtp_profile(v_a_crypto ? 1 : 0, p->vrtp,
+				ast_sdp_get_rtp_profile((v_a_crypto || p->dtls_cfg.enabled), p->vrtp,
 					ast_test_flag(&p->flags[2], SIP_PAGE3_USE_AVPF)));
 
 			/* Build max bitrate string */
@@ -13261,7 +13267,7 @@
 		a_crypto = crypto_get_attrib(p->srtp, p->dtls_cfg.enabled,
 			ast_test_flag(&p->flags[2], SIP_PAGE3_SRTP_TAG_32));
 		ast_str_append(&m_audio, 0, "m=audio %d %s", ast_sockaddr_port(&dest),
-			ast_sdp_get_rtp_profile(a_crypto ? 1 : 0, p->rtp,
+			ast_sdp_get_rtp_profile((a_crypto || p->dtls_cfg.enabled), p->rtp,
 				ast_test_flag(&p->flags[2], SIP_PAGE3_USE_AVPF)));
 
 		/* Now, start adding audio codecs. These are added in this order:




More information about the asterisk-commits mailing list