[asterisk-commits] twilson: branch 1.8 r341379 - in /branches/1.8: channels/ include/asterisk/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Oct 19 02:38:56 CDT 2011


Author: twilson
Date: Wed Oct 19 02:38:52 2011
New Revision: 341379

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=341379
Log:
Don't use is_int() since it doesn't link well on all platforms

Just create an normal API function in strings.h that does the same thing
just to be safe.

Modified:
    branches/1.8/channels/chan_sip.c
    branches/1.8/include/asterisk/strings.h

Modified: branches/1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_sip.c?view=diff&rev=341379&r1=341378&r2=341379
==============================================================================
--- branches/1.8/channels/chan_sip.c (original)
+++ branches/1.8/channels/chan_sip.c Wed Oct 19 02:38:52 2011
@@ -264,7 +264,6 @@
 #include "asterisk/cel.h"
 #include "asterisk/data.h"
 #include "asterisk/aoc.h"
-#include "asterisk/pval.h"
 #include "sip/include/sip.h"
 #include "sip/include/globals.h"
 #include "sip/include/config_parser.h"
@@ -5273,7 +5272,7 @@
 		dialog->relatedpeer = ref_peer(peer, "create_addr: setting dialog's relatedpeer pointer");
 		unref_peer(peer, "create_addr: unref peer from find_peer hashtab lookup");
 		return res;
-	} else if (is_int(peername)) {
+	} else if (ast_check_digits(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 */

Modified: branches/1.8/include/asterisk/strings.h
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/include/asterisk/strings.h?view=diff&rev=341379&r1=341378&r2=341379
==============================================================================
--- branches/1.8/include/asterisk/strings.h (original)
+++ branches/1.8/include/asterisk/strings.h Wed Oct 19 02:38:52 2011
@@ -872,6 +872,25 @@
 )
 
 /*!
+ * \brief Check if a string is only digits
+ *
+ * \retval 1 The string contains only digits
+ * \retval 0 The string contains non-digit characters
+ */
+AST_INLINE_API(
+int ast_check_digits(char *arg),
+{
+	char *s;
+	for (s=arg; *s; s++) {
+		if (*s < '0' || *s > '9') {
+			return 0;
+		}
+	}
+	return 1;
+}
+)
+
+/*!
  * \brief Compute a hash value on a string
  *
  * This famous hash algorithm was written by Dan Bernstein and is




More information about the asterisk-commits mailing list