[Asterisk-code-review] res_pjsip_session: Ensure reused streams have correct bundle group (asterisk[16])

Friendly Automation asteriskteam at digium.com
Tue Jul 28 12:05:36 CDT 2020


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/14713 )

Change subject: res_pjsip_session: Ensure reused streams have correct bundle group
......................................................................

res_pjsip_session: Ensure reused streams have correct bundle group

When a bundled stream is removed, its bundle_group is reset to -1.
If that stream is later reused, the bundle parameters on session
media need to be reset correctly it could mistakenly be rebundled
with a stream that was removed and never reused.  Since the removed
stream has no rtp instance, a crash will result.

Change-Id: Ie2b792220f9291587ab5f9fd123145559dba96d7
---
M res/res_pjsip_session.c
1 file changed, 14 insertions(+), 0 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c
index f34f7c9..ab558f6 100644
--- a/res/res_pjsip_session.c
+++ b/res/res_pjsip_session.c
@@ -487,6 +487,20 @@
 		/* A stream can never exist without an accompanying media session */
 		if (session_media->type == type) {
 			ao2_ref(session_media, +1);
+			/*
+			 * If this session_media was previously removed, its bundle group was probably reset
+			 * to -1 so if bundling is enabled on the endpoint, we need to reset it to 0, set
+			 * the bundled flag and reset its mid.
+			 */
+			if (session->endpoint->media.bundle && session_media->bundle_group == -1) {
+				session_media->bundled = session->endpoint->media.webrtc;
+				session_media->bundle_group = 0;
+				ast_free(session_media->mid);
+				if (ast_asprintf(&session_media->mid, "%s-%d", ast_codec_media_type2str(type), position) < 0) {
+					ao2_ref(session_media, -1);
+					return NULL;
+				}
+			}
 		} else {
 			session_media = NULL;
 		}

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14713
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: Ie2b792220f9291587ab5f9fd123145559dba96d7
Gerrit-Change-Number: 14713
Gerrit-PatchSet: 2
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200728/199bb725/attachment-0001.html>


More information about the asterisk-code-review mailing list