[svn-commits] twilson: trunk r341316 - in /trunk: ./ channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Oct 18 18:45:44 CDT 2011


Author: twilson
Date: Tue Oct 18 18:45:35 2011
New Revision: 341316

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=341316
Log:
Don't resolve numeric hosts or contact unresolved hosts

If a SIP dial string contains a numeric hostname that is not a peer name,
don't try to resolve it as it is unlikely that someone really means
Dial(SIP/0.0.4.26) when Dial(SIP/1050) is called. Also, make sure that
create_addr returns -1 if an address isn't resolved so that we don't
attempt to send SIP requests to an address that doesn't resolve.

(closes issue ASTERISK-17146, ASTERISK-17716)

Review: https://reviewboard.asterisk.org/r/1532/
........

Merged revisions 341314 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 341315 from http://svn.asterisk.org/svn/asterisk/branches/10

Modified:
    trunk/   (props changed)
    trunk/channels/chan_sip.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=341316&r1=341315&r2=341316
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue Oct 18 18:45:35 2011
@@ -265,6 +265,7 @@
 #include "asterisk/data.h"
 #include "asterisk/aoc.h"
 #include "asterisk/message.h"
+#include "asterisk/pval.h"
 #include "sip/include/sip.h"
 #include "sip/include/globals.h"
 #include "sip/include/config_parser.h"
@@ -5314,6 +5315,12 @@
 		dialog->relatedpeer = sip_ref_peer(peer, "create_addr: setting dialog's relatedpeer pointer");
 		sip_unref_peer(peer, "create_addr: unref peer from sip_find_peer hashtab lookup");
 		return res;
+	} else if (is_int(peername)) {
+		/* Although an IPv4 hostname *could* be represented as a 32-bit integer, it is uncommon and
+		 * it makes dialing SIP/${EXTEN} for a peer that isn't defined resolve to an IP that is
+		 * almost certainly not intended. It is much better to just reject purely numeric hostnames */
+		ast_log(LOG_WARNING, "Purely numeric hostname (%s), and not a peer--rejecting!\n", peername);
+		return -1;
 	} else {
 		dialog->rtptimeout = global_rtptimeout;
 		dialog->rtpholdtimeout = global_rtpholdtimeout;
@@ -5355,6 +5362,7 @@
 
 		if (ast_sockaddr_resolve_first(&dialog->sa, hostn, 0)) {
 			ast_log(LOG_WARNING, "No such host: %s\n", peername);
+			return -1;
 		}
 
 		if (srv_ret > 0) {




More information about the svn-commits mailing list