[Asterisk-cvs] asterisk utils.c,1.1,1.2
markster at lists.digium.com
markster at lists.digium.com
Tue May 11 14:30:54 CDT 2004
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv24392
Modified Files:
utils.c
Log Message:
Refuse to gethostbyname on a pure integer
Index: utils.c
===================================================================
RCS file: /usr/cvsroot/asterisk/utils.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- utils.c 9 May 2004 08:22:15 -0000 1.1
+++ utils.c 11 May 2004 18:41:09 -0000 1.2
@@ -9,6 +9,7 @@
* the GNU General Public License
*/
+#include <ctype.h>
#include <asterisk/lock.h>
#include <asterisk/utils.h>
@@ -120,8 +121,20 @@
{
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])
More information about the svn-commits
mailing list