[asterisk-commits] mmichelson: trunk r279888 - in /trunk: ./ channels/chan_sip.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 27 13:55:10 CDT 2010
Author: mmichelson
Date: Tue Jul 27 13:55:06 2010
New Revision: 279888
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=279888
Log:
Merged revisions 279887 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r279887 | mmichelson | 2010-07-27 13:54:07 -0500 (Tue, 27 Jul 2010) | 16 lines
Fix parsing error in sip_sipredirect().
The code was written in a way that did a bad job of
parsing the port out of a URI. Specifically, it would
do badly when dealing with an IPv6 address. In this
particular scenario, there was no value from parsing
the port out, so I just removed that logic. And while
I was messing around in the function, I changed some
variable names to be more descriptive.
(closes issue #17661)
Reported by: oej
Patches:
17661.diff uploaded by mmichelson (license 60)
........
Modified:
trunk/ (props changed)
trunk/channels/chan_sip.c
Propchange: trunk/
------------------------------------------------------------------------------
--- branch-1.8-merged (original)
+++ branch-1.8-merged Tue Jul 27 13:55:06 2010
@@ -1,1 +1,1 @@
-/branches/1.8:1-279056,279113,279227,279273,279280,279314,279390,279410,279442,279472,279502,279504,279562,279566,279568,279598,279601,279619,279636-279815,279817,279850
+/branches/1.8:1-279056,279113,279227,279273,279280,279314,279390,279410,279442,279472,279502,279504,279562,279566,279568,279598,279601,279619,279636-279815,279817,279850,279887
Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=279888&r1=279887&r2=279888
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue Jul 27 13:55:06 2010
@@ -27462,49 +27462,44 @@
static int sip_sipredirect(struct sip_pvt *p, const char *dest)
{
char *cdest;
- char *extension, *host, *port;
- char tmp[80];
+ char *extension, *domain;
cdest = ast_strdupa(dest);
extension = strsep(&cdest, "@");
- host = strsep(&cdest, ":");
- port = strsep(&cdest, ":");
+ domain = strsep(&cdest, ":");
if (ast_strlen_zero(extension)) {
ast_log(LOG_ERROR, "Missing mandatory argument: extension\n");
return 0;
}
/* we'll issue the redirect message here */
- if (!host) {
- char *localtmp;
-
- ast_copy_string(tmp, get_header(&p->initreq, "To"), sizeof(tmp));
- if (ast_strlen_zero(tmp)) {
+ if (!domain) {
+ char *local_to_header;
+ char to_header[256];
+
+ ast_copy_string(to_header, get_header(&p->initreq, "To"), sizeof(to_header));
+ if (ast_strlen_zero(to_header)) {
ast_log(LOG_ERROR, "Cannot retrieve the 'To' header from the original SIP request!\n");
return 0;
}
- if ( ( (localtmp = strcasestr(tmp, "sip:")) || (localtmp = strcasestr(tmp, "sips:")) )
- && (localtmp = strchr(localtmp, '@'))) {
- char lhost[80], lport[80];
-
- memset(lhost, 0, sizeof(lhost));
- memset(lport, 0, sizeof(lport));
- localtmp++;
+ if (((local_to_header = strcasestr(to_header, "sip:")) || (local_to_header = strcasestr(to_header, "sips:")))
+ && (local_to_header = strchr(local_to_header, '@'))) {
+ char ldomain[256];
+
+ memset(ldomain, 0, sizeof(ldomain));
+ local_to_header++;
/* This is okey because lhost and lport are as big as tmp */
- sscanf(localtmp, "%80[^<>:; ]:%80[^<>:; ]", lhost, lport);
- if (ast_strlen_zero(lhost)) {
+ sscanf(local_to_header, "%256[^<>; ]", ldomain);
+ if (ast_strlen_zero(ldomain)) {
ast_log(LOG_ERROR, "Can't find the host address\n");
return 0;
}
- host = ast_strdupa(lhost);
- if (!ast_strlen_zero(lport)) {
- port = ast_strdupa(lport);
- }
- }
- }
-
- ast_string_field_build(p, our_contact, "Transfer <sip:%s@%s%s%s>", extension, host, port ? ":" : "", port ? port : "");
+ domain = ast_strdupa(ldomain);
+ }
+ }
+
+ ast_string_field_build(p, our_contact, "Transfer <sip:%s@%s>", extension, domain);
transmit_response_reliable(p, "302 Moved Temporarily", &p->initreq);
sip_scheddestroy(p, SIP_TRANS_TIMEOUT); /* Make sure we stop send this reply. */
More information about the asterisk-commits
mailing list