[asterisk-commits] res pjsip sdp rtp: Limit number of formats to defined maximum. (asterisk[14])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 2 09:38:17 CDT 2016


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/4266 )

Change subject: res_pjsip_sdp_rtp: Limit number of formats to defined maximum.
......................................................................


res_pjsip_sdp_rtp: Limit number of formats to defined maximum.

The res_pjsip_sdp_rtp module did not restrict the number of
formats added to a media stream in the SDP to the defined
limit. If allow=all was used with additional loaded codecs this
could result in the next media stream being overwritten some.

This change restricts the module to limit it to the defined
maximum and also increases the maximum in our bundled pjproject.

ASTERISK-26541 #close

Change-Id: I0dc5f59d3891246cafa2f3df5ec406f088559ee8
---
M res/res_pjsip_sdp_rtp.c
M third-party/pjproject/patches/config_site.h
2 files changed, 15 insertions(+), 1 deletion(-)

Approvals:
  Mark Michelson: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Anonymous Coward #1000019: Verified



diff --git a/res/res_pjsip_sdp_rtp.c b/res/res_pjsip_sdp_rtp.c
index aad6bb8..d8b94df 100644
--- a/res/res_pjsip_sdp_rtp.c
+++ b/res/res_pjsip_sdp_rtp.c
@@ -1180,10 +1180,14 @@
 			max_packet_size = ast_format_get_maximum_ms(format);
 		}
 		ao2_ref(format, -1);
+
+		if (media->desc.fmt_count == PJMEDIA_MAX_SDP_FMT) {
+			break;
+		}
 	}
 
 	/* Add non-codec formats */
-	if (media_type != AST_MEDIA_TYPE_VIDEO) {
+	if (media_type != AST_MEDIA_TYPE_VIDEO && media->desc.fmt_count < PJMEDIA_MAX_SDP_FMT) {
 		for (index = 1LL; index <= AST_RTP_MAX; index <<= 1) {
 			if (!(noncodec & index)) {
 				continue;
@@ -1205,6 +1209,10 @@
 				attr = pjmedia_sdp_attr_create(pool, "fmtp", pj_cstr(&stmp, tmp));
 				media->attr[media->attr_count++] = attr;
 			}
+
+			if (media->desc.fmt_count == PJMEDIA_MAX_SDP_FMT) {
+				break;
+			}
 		}
 	}
 
diff --git a/third-party/pjproject/patches/config_site.h b/third-party/pjproject/patches/config_site.h
index 0694f12..564959d 100644
--- a/third-party/pjproject/patches/config_site.h
+++ b/third-party/pjproject/patches/config_site.h
@@ -57,3 +57,9 @@
 /* Defaults too low for WebRTC */
 #define PJ_ICE_MAX_CAND 32
 #define PJ_ICE_MAX_CHECKS (PJ_ICE_MAX_CAND * 2)
+
+/* Increase limits to allow more formats */
+#define	PJMEDIA_MAX_SDP_FMT   64
+#define	PJMEDIA_MAX_SDP_BANDW   4
+#define	PJMEDIA_MAX_SDP_ATTR   (PJMEDIA_MAX_SDP_FMT*2 + 4)
+#define	PJMEDIA_MAX_SDP_MEDIA   16

-- 
To view, visit https://gerrit.asterisk.org/4266
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0dc5f59d3891246cafa2f3df5ec406f088559ee8
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-commits mailing list