[asterisk-commits] trunk - r7861 /trunk/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Jan 7 15:30:20 CST 2006


Author: markster
Date: Sat Jan  7 15:30:19 2006
New Revision: 7861

URL: http://svn.digium.com/view/asterisk?rev=7861&view=rev
Log:
Handle swapout of "fromdomain" in callid properly (bug #6154)

Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=7861&r1=7860&r2=7861&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Sat Jan  7 15:30:19 2006
@@ -1830,8 +1830,6 @@
 /*! \brief  create_addr_from_peer: create address structure from peer reference ---*/
 static int create_addr_from_peer(struct sip_pvt *r, struct sip_peer *peer)
 {
-	char *callhost;
-
 	if ((peer->addr.sin_addr.s_addr || peer->defaddr.sin_addr.s_addr) &&
 	    (!peer->maxms || ((peer->lastms >= 0)  && (peer->lastms <= peer->maxms)))) {
 		if (peer->addr.sin_addr.s_addr) {
@@ -1867,8 +1865,15 @@
 	ast_string_field_set(r, tohost, peer->tohost);
 	ast_string_field_set(r, fullcontact, peer->fullcontact);
 	if (!r->initreq.headers && !ast_strlen_zero(peer->fromdomain)) {
-		if ((callhost = strchr(r->callid, '@'))) {
-			strncpy(callhost + 1, peer->fromdomain, sizeof(r->callid) - (callhost - r->callid) - 2);
+		char *tmpcall;
+		char *c;
+		tmpcall = ast_strdupa(r->callid);
+		if (tmpcall) {
+			c = strchr(tmpcall, '@');
+			if (c) {
+				*c = '\0';
+				ast_string_field_build(r, callid, "%s@%s", tmpcall, peer->fromdomain);
+			}
 		}
 	}
 	if (ast_strlen_zero(r->tohost)) {



More information about the asterisk-commits mailing list