summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--channels/chan_sip.c3
-rw-r--r--include/asterisk/strings.h19
2 files changed, 20 insertions, 2 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index ac17f78fa..20498a00a 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -265,7 +265,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#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"
@@ -5315,7 +5314,7 @@ static int create_addr(struct sip_pvt *dialog, const char *opeer, struct ast_soc
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)) {
+ } 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 */
diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h
index 49d3e0da8..cd69c6b6b 100644
--- a/include/asterisk/strings.h
+++ b/include/asterisk/strings.h
@@ -872,6 +872,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
*
* This famous hash algorithm was written by Dan Bernstein and is