[Asterisk-code-review] res/res_pjsip_diversion: prevent crash on tel: uri in History-Info (asterisk[master])

Joshua Colp asteriskteam at digium.com
Mon Jan 4 04:09:31 CST 2021


Joshua Colp has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/15273 )

Change subject: res/res_pjsip_diversion: prevent crash on tel: uri in History-Info
......................................................................

res/res_pjsip_diversion: prevent crash on tel: uri in History-Info

Add a check to see if the URI is a Tel URI and prevent crashing on
trying to retrieve the reason parameter.

ASTERISK-29191
ASTERISK-29219

Change-Id: I0320aa205f22cda511d60a2edf2b037e8fd6cc37
(cherry picked from commit a7aea71e60d513af82c6e3825e2308e063139b63)
---
M res/res_pjsip_diversion.c
1 file changed, 9 insertions(+), 2 deletions(-)

Approvals:
  George Joseph: Looks good to me, approved
  Joshua Colp: Approved for Submit



diff --git a/res/res_pjsip_diversion.c b/res/res_pjsip_diversion.c
index 7153b54..24d1781 100644
--- a/res/res_pjsip_diversion.c
+++ b/res/res_pjsip_diversion.c
@@ -314,8 +314,14 @@
 {
 	static const pj_str_t cause_name = { "cause", 5 };
 	pjsip_sip_uri *uri = pjsip_uri_get_uri(name_addr);
-	pjsip_param *cause = pjsip_param_find(&uri->other_param, &cause_name);
-	unsigned long cause_value;
+	pjsip_param *cause = NULL;
+	unsigned long cause_value = 0;
+
+	if (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri)) {
+		return;
+	}
+
+	cause = pjsip_param_find(&uri->other_param, &cause_name);
 
 	if (!cause) {
 		return;
@@ -377,6 +383,7 @@
 	ast_party_redirecting_init(&data);
 	memset(&update, 0, sizeof(update));
 
+	data.reason.code = AST_REDIRECTING_REASON_UNKNOWN;
 	if (from_info) {
 		set_redirecting_id((pjsip_name_addr*)from_info->uri,
 			&data.from, &update.from);

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I0320aa205f22cda511d60a2edf2b037e8fd6cc37
Gerrit-Change-Number: 15273
Gerrit-PatchSet: 2
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Torrey Searle <tsearle at gmail.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210104/9e5c13b4/attachment.html>


More information about the asterisk-code-review mailing list