diff options
author | zuul <zuul@gerrit.asterisk.org> | 2017-03-22 12:36:51 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-03-22 12:36:51 -0500 |
commit | 5f75cc8279be1d48776011264b9f83a5eb8c723c (patch) | |
tree | 2a05b906f52e4c85c31f5274e6899155a5926a29 | |
parent | d7c52125e97aaa0034d31cfaad57e7f7405e9e44 (diff) | |
parent | b3cc20799bcdd2114026ec943e6879434116406b (diff) |
Merge "res_pjsip_messaging: Check URI type before dereferencing" into 13
-rw-r--r-- | main/message.c | 6 | ||||
-rw-r--r-- | res/res_pjsip_messaging.c | 10 |
2 files changed, 13 insertions, 3 deletions
diff --git a/main/message.c b/main/message.c index 594853f3f..be0035d30 100644 --- a/main/message.c +++ b/main/message.c @@ -127,8 +127,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") </parameter> <parameter name="from" required="false"> <para>A From URI for the message if needed for the - message technology being used to send this message.</para> - <xi:include xpointer="xpointer(/docs/info[@name='MessageFromInfo'])" /> + message technology being used to send this message. This can be a + SIP(S) URI, such as <literal>Alice <sip:alice@atlanta.com></literal>, + a string in the format <literal>alice@atlanta.com</literal>, or simply + a username such as <literal>alice</literal>.</para> </parameter> </syntax> <description> diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c index 835a38393..8b465e007 100644 --- a/res/res_pjsip_messaging.c +++ b/res/res_pjsip_messaging.c @@ -235,7 +235,15 @@ static void update_from(pjsip_tx_data *tdata, char *from) parsed_name_addr = (pjsip_name_addr *) pjsip_parse_uri(tdata->pool, from, strlen(from), PJSIP_PARSE_URI_AS_NAMEADDR); if (parsed_name_addr) { - pjsip_sip_uri *parsed_uri = pjsip_uri_get_uri(parsed_name_addr->uri); + pjsip_sip_uri *parsed_uri; + + if (!PJSIP_URI_SCHEME_IS_SIP(parsed_name_addr->uri) + && !PJSIP_URI_SCHEME_IS_SIPS(parsed_name_addr->uri)) { + ast_log(LOG_WARNING, "From address '%s' is not a valid SIP/SIPS URI\n", from); + return; + } + + parsed_uri = pjsip_uri_get_uri(parsed_name_addr->uri); if (pj_strlen(&parsed_name_addr->display)) { pj_strdup(tdata->pool, &name_addr->display, &parsed_name_addr->display); |