Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 7840) +++ channels/chan_sip.c (working copy) @@ -1830,7 +1830,9 @@ /*! \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; + char tmpcall[256]; + char *pos; + int len; if ((peer->addr.sin_addr.s_addr || peer->defaddr.sin_addr.s_addr) && (!peer->maxms || ((peer->lastms >= 0) && (peer->lastms <= peer->maxms)))) { @@ -1867,8 +1869,14 @@ 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); + if ((pos = strchr(r->callid, '@'))) { + pos[0]=0; + len=strlen(r->callid); + if(len > sizeof(tmpcall)) + len=sizeof(tmpcall)-1; + strncpy(tmpcall, r->callid, len); + tmpcall[len]= 0; + ast_string_field_build(r, callid, "%s@%s", tmpcall, peer->fromdomain); } } if (ast_strlen_zero(r->tohost)) {