diff options
author | Benjamin Keith Ford <bford@digium.com> | 2017-07-07 11:19:13 -0500 |
---|---|---|
committer | Benjamin Keith Ford <bford@digium.com> | 2017-07-10 09:55:05 -0500 |
commit | 8f72128e661c34b626a71d25fd0d2e9d694e51ba (patch) | |
tree | cd5e64ba6ef55bcb23dcd29e9044a26225dbd1f4 /res/res_pjsip.c | |
parent | 17103ca898f077846c4b1430091ba37454476844 (diff) |
res_pjsip: Fix crash with from_user containing invalid characters.
If the from_user field contains certain characters (like @, {, ^, etc.),
PJSIP will return a null value for the URI when attempting to parse it.
This causes a crash when trying to dial out through a trunk that contains
these invalid characters in its from_user field.
This change checks the configuration and ensures that an endpoint will
not be created if the from_user contains an invalid character. It also
adds a null check to the PJSIP URI parsing as a backup.
ASTERISK-27036 #close
Reported by: Maxim Vasilev
Change-Id: I0396fdb5080604e0bdf1277464d5c8a85db913d0
Diffstat (limited to 'res/res_pjsip.c')
-rw-r--r-- | res/res_pjsip.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/res/res_pjsip.c b/res/res_pjsip.c index 8923540a9..6e389d5f3 100644 --- a/res/res_pjsip.c +++ b/res/res_pjsip.c @@ -3091,6 +3091,14 @@ pjsip_dialog *ast_sip_create_dialog_uac(const struct ast_sip_endpoint *endpoint, /* Update the dialog with the new local URI, we do it afterwards so we can use the dialog pool for construction */ pj_strdup_with_null(dlg->pool, &dlg->local.info_str, &local_uri); dlg->local.info->uri = pjsip_parse_uri(dlg->pool, dlg->local.info_str.ptr, dlg->local.info_str.slen, 0); + if (!dlg->local.info->uri) { + ast_log(LOG_ERROR, + "Could not parse URI '%s' for endpoint '%s'\n", + dlg->local.info_str.ptr, ast_sorcery_object_get_id(endpoint)); + dlg->sess_count--; + pjsip_dlg_terminate(dlg); + return NULL; + } dlg->local.contact = pjsip_parse_hdr(dlg->pool, &HCONTACT, local_uri.ptr, local_uri.slen, NULL); |