Skip to content
Snippets Groups Projects
Commit 76394a72 authored by Matthew Jordan's avatar Matthew Jordan
Browse files

Fixed SendMessage stripping extension from To: header in SIP MESSAGE

When using the MessageSend application to send a SIP MESSAGE to a non-peer,
chan_sip attempted to validate the hostname or IP Address.  In the process,
it stripped off the extension and failed to add it back to the sip_pvt
structure before transmitting.  This patch adds the full URI passed in
from the message core to the sip_pvt structure.

(closes issue ASTERISK-18903)
Reported by: Shaun Clark
Tested by: Matt Jordan

Review: https://reviewboard.asterisk.org/r/1597/
........

Merged revisions 346040 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@346053 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 6d05a31d
No related branches found
No related tags found
No related merge requests found
...@@ -24315,20 +24315,25 @@ static int sip_msg_send(const struct ast_msg *msg, const char *to, const char *f ...@@ -24315,20 +24315,25 @@ static int sip_msg_send(const struct ast_msg *msg, const char *to, const char *f
{ {
struct sip_pvt *pvt; struct sip_pvt *pvt;
int res; int res;
char *peer; char *uri, *host;
struct sip_peer *peer_ptr; struct sip_peer *peer_ptr;
   
if (!(pvt = sip_alloc(NULL, NULL, 0, SIP_MESSAGE, NULL))) { if (!(pvt = sip_alloc(NULL, NULL, 0, SIP_MESSAGE, NULL))) {
return -1; return -1;
} }
   
peer = ast_strdupa(to); uri = ast_strdupa(to);
if (strchr(peer, '@')) { if (!strncasecmp(uri, "sip:", 4)) {
strsep(&peer, "@"); uri += 4;
} else { } else if (!strncasecmp(uri, "sips:", 5)) {
strsep(&peer, ":"); uri += 5;
} }
if (ast_strlen_zero(peer)) { host = ast_strdupa(uri);
if (strchr(host, '@')) {
strsep(&host, "@");
}
if (ast_strlen_zero(host)) {
ast_log(LOG_WARNING, "MESSAGE(to) is invalid for SIP - '%s'\n", to); ast_log(LOG_WARNING, "MESSAGE(to) is invalid for SIP - '%s'\n", to);
dialog_unlink_all(pvt); dialog_unlink_all(pvt);
dialog_unref(pvt, "MESSAGE(to) is invalid for SIP"); dialog_unref(pvt, "MESSAGE(to) is invalid for SIP");
...@@ -24364,12 +24369,16 @@ static int sip_msg_send(const struct ast_msg *msg, const char *to, const char *f ...@@ -24364,12 +24369,16 @@ static int sip_msg_send(const struct ast_msg *msg, const char *to, const char *f
   
sip_pvt_lock(pvt); sip_pvt_lock(pvt);
   
if (create_addr(pvt, peer, NULL, TRUE, NULL)) { /* Look up the host to contact */
if (create_addr(pvt, host, NULL, TRUE, NULL)) {
sip_pvt_unlock(pvt); sip_pvt_unlock(pvt);
dialog_unlink_all(pvt); dialog_unlink_all(pvt);
dialog_unref(pvt, "create_addr failed sending a MESSAGE"); dialog_unref(pvt, "create_addr failed sending a MESSAGE");
return -1; return -1;
} }
/* Set the tohost to the full URI provided */
ast_string_field_set(pvt, tohost, uri);
ast_sip_ouraddrfor(&pvt->sa, &pvt->ourip, pvt); ast_sip_ouraddrfor(&pvt->sa, &pvt->ourip, pvt);
ast_set_flag(&pvt->flags[0], SIP_OUTGOING); ast_set_flag(&pvt->flags[0], SIP_OUTGOING);
   
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment