]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_sdp_rtp: Limit number of formats to defined maximum. 66/4266/1
authorJoshua Colp <jcolp@digium.com>
Tue, 1 Nov 2016 11:56:24 +0000 (11:56 +0000)
committerJoshua Colp <jcolp@digium.com>
Tue, 1 Nov 2016 11:56:24 +0000 (11:56 +0000)
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

res/res_pjsip_sdp_rtp.c
third-party/pjproject/patches/config_site.h

index aad6bb88f0f9cea4b6415662ed6e48f9e8d81057..d8b94df9f1a04291ba1977ce5d36e3ea5d468d1e 100644 (file)
@@ -1180,10 +1180,14 @@ static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct as
                        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 @@ static int create_outgoing_sdp_stream(struct ast_sip_session *session, struct as
                                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;
+                       }
                }
        }
 
index 0694f120e8723e31f26786a78fde39c11463fe94..564959d84c40e7f4c3ebe7afb89fb78022f7d24d 100644 (file)
@@ -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