]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Don't use is_int() since it doesn't link well on all platforms
authorTerry Wilson <twilson@digium.com>
Wed, 19 Oct 2011 07:38:52 +0000 (07:38 +0000)
committerTerry Wilson <twilson@digium.com>
Wed, 19 Oct 2011 07:38:52 +0000 (07:38 +0000)
Just create an normal API function in strings.h that does the same thing
just to be safe.

ASTERISK-17146

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@341379 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c
include/asterisk/strings.h

index 717a152dbc074ce15f8e2da383febba45a9541c2..ad716ec0293c599e30cc4af1e3888fbe4961c49a 100644 (file)
@@ -264,7 +264,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #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 @@ static int create_addr(struct sip_pvt *dialog, const char *opeer, struct ast_soc
                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 */
index 49d3e0da85d59db965d69facb22333d79ffb6240..cd69c6b6b99eb3379257a1eb2596b8e4ae692ae1 100644 (file)
@@ -871,6 +871,25 @@ int __attribute__((format(printf, 3, 4))) ast_str_append(
 }
 )
 
+/*!
+ * \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
  *