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

George Joseph asteriskteam at digium.com
Tue Dec 22 11:40:55 CST 2020


Attention is currently required from: Torrey Searle.
Hello Torrey Searle,

I'd like you to do a code review. Please visit

    https://gerrit.asterisk.org/c/asterisk/+/15262

to review the following change.


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
---
M res/res_pjsip_diversion.c
1 file changed, 12 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/62/15262/1

diff --git a/res/res_pjsip_diversion.c b/res/res_pjsip_diversion.c
index 5b400d2..45c9803 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,10 +383,13 @@
 	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);
-		set_redirecting_reason(from_info, to_info, &data.reason);
+		if (to_info) {
+			set_redirecting_reason(from_info, to_info, &data.reason);
+		}
 		ast_set_party_id_all(&update.priv_to);
 	} else {
 		copy_redirecting_id(&data.from, &session->id, &update.from);

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

Gerrit-Project: asterisk
Gerrit-Branch: 13.38
Gerrit-Change-Id: I0320aa205f22cda511d60a2edf2b037e8fd6cc37
Gerrit-Change-Number: 15262
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Torrey Searle <tsearle at gmail.com>
Gerrit-Attention: Torrey Searle <tsearle at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20201222/16be2396/attachment.html>


More information about the asterisk-code-review mailing list