aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
Diffstat (limited to 'channels')
-rwxr-xr-xchannels/chan_sip.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 74ae10c48..10f2075cf 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -4740,7 +4740,10 @@ static int sip_poke_peer(struct sip_peer *peer)
}
memcpy(&p->sa, &peer->addr, sizeof(p->sa));
memcpy(&p->recv, &peer->addr, sizeof(p->sa));
- strncpy(p->tohost, peer->tohost, sizeof(p->tohost) - 1);
+ if (strlen(p->tohost))
+ strncpy(p->tohost, peer->tohost, sizeof(p->tohost) - 1);
+ else
+ snprintf(p->tohost, sizeof(p->tohost), "%s", inet_ntoa(p->addr.sin_addr));
/* Recalculate our side, and recalculate Call ID */
memcpy(&p->ourip, myaddrfor(&p->sa.sin_addr), sizeof(p->ourip));