--- asterisk-1.4.23/channels/chan_sip.c 2009-01-13 19:34:14.000000000 +0100 +++ asterisk-1.4.23-patched/channels/chan_sip.c 2009-02-06 10:46:52.000000000 +0100 @@ -2912,7 +2914,7 @@ struct ast_hostent ahp; struct sip_peer *p; char *port; - int portno; + int portno=0; char host[MAXHOSTNAMELEN], *hostn; char peer[256]; @@ -2934,8 +2936,8 @@ return res; } hostn = peer; - portno = port ? atoi(port) : STANDARD_SIP_PORT; - if (srvlookup) { + /* if the URI contains a port we must not perform an SRV lookup */ + if (!port && srvlookup) { char service[MAXHOSTNAMELEN]; int tportno; int ret; @@ -2946,7 +2948,10 @@ hostn = host; portno = tportno; } - } + } + if (!portno) + portno = port ? atoi(port) : STANDARD_SIP_PORT; + hp = ast_gethostbyname(hostn, &ahp); if (!hp) { ast_log(LOG_WARNING, "No such host: %s\n", peer);