From: Mark Spencer Date: Sat, 17 Jul 2004 23:27:11 +0000 (+0000) Subject: Don't consider port number in name of peer in create_addr (bug #1974) X-Git-Tag: 1.0.0-rc2~138 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=463444b3912197a7d23947f33076eb5009dca9dc;p=thirdparty%2Fasterisk.git Don't consider port number in name of peer in create_addr (bug #1974) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3466 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 78168b61f4..1f3dcec8df 100755 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -1236,7 +1236,7 @@ static struct sip_user *find_user(char *name) /*--- create_addr: create address structure from peer definition ---*/ /* Or, if peer not found, find it in the global DNS */ /* returns TRUE on failure, FALSE on success */ -static int create_addr(struct sip_pvt *r, char *peer) +static int create_addr(struct sip_pvt *r, char *opeer) { struct hostent *hp; struct ast_hostent ahp; @@ -1245,7 +1245,14 @@ static int create_addr(struct sip_pvt *r, char *peer) char *port; int portno; char host[256], *hostn; + char peer[256]=""; + strncpy(peer, opeer, sizeof(peer) - 1); + port = strchr(peer, ':'); + if (port) { + *port = '\0'; + port++; + } r->sa.sin_family = AF_INET; ast_mutex_lock(&peerl.lock); p = find_peer(peer, NULL); @@ -1314,10 +1321,6 @@ static int create_addr(struct sip_pvt *r, char *peer) } ast_mutex_unlock(&peerl.lock); if (!p && !found) { - if ((port=strchr(peer, ':'))) { - *port='\0'; - port++; - } hostn = peer; if (port) portno = atoi(port);