]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res/res_pjsip_diversion: prevent crash on tel: uri in History-Info
authorTorrey Searle <tsearle@voxbone.com>
Tue, 22 Dec 2020 08:58:39 +0000 (09:58 +0100)
committerGeorge Joseph <gjoseph@digium.com>
Tue, 22 Dec 2020 19:00:25 +0000 (13:00 -0600)
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

res/res_pjsip_diversion.c

index 5b400d2829c8ef426f87bd1f123b067b0a407083..08f75e090363d8f7feb9358f9226cb7579625dd6 100644 (file)
@@ -314,8 +314,14 @@ static void set_redirecting_reason_by_cause(pjsip_name_addr *name_addr,
 {
        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 @@ static void set_redirecting(struct ast_sip_session *session,
        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);