diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-05-11 18:41:09 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-05-11 18:41:09 +0000 |
commit | b3b27f9f92a01f0bcdf1faa3e9e1e5442eac6ae7 (patch) | |
tree | 1bebdc09c56b584cfac65712d0fab6973b8b4e3f /utils.c | |
parent | 5911a737965ad27cd031c7f782913e47a7a3172c (diff) |
Refuse to gethostbyname on a pure integer
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2949 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'utils.c')
-rwxr-xr-x | utils.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -9,6 +9,7 @@ * the GNU General Public License */ +#include <ctype.h> #include <asterisk/lock.h> #include <asterisk/utils.h> @@ -120,8 +121,20 @@ struct hostent *ast_gethostbyname(const char *host, struct ast_hostent *hp) { int res; int herrno; + const char *s; struct hostent *result = NULL; - + /* Although it is perfectly legitimate to lookup a pure integer, for + the sake of the sanity of people who like to name their peers as + integers, we break with tradition and refuse to look up a + pure integer */ + s = host; + while(s && *s) { + if (!isdigit(*s)) + break; + s++; + } + if (!s || !*s) + return NULL; res = gethostbyname_r(host, &hp->hp, hp->buf, sizeof(hp->buf), &result, &herrno); if (res || !hp->hp.h_addr_list || !hp->hp.h_addr_list[0]) |