Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 341249) +++ channels/chan_sip.c (working copy) @@ -264,6 +264,7 @@ #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" @@ -5272,6 +5273,12 @@ 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)) { + /* 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; @@ -5313,6 +5320,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) {