From 5b02b8768dd6066e2083987703951baa50c96e62 Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 2 Aug 2006 12:50:41 +0000 Subject: Check for invalid ip's being bound to git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4638 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/socket.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/socket.cpp b/src/socket.cpp index e386e8188..d1eca25fc 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -28,21 +28,23 @@ extern ServerConfig* Config; extern time_t TIME; /** This will bind a socket to a port. It works for UDP/TCP. - * If a hostname is given to bind to, the function will first - * attempt to resolve the hostname, then bind to the IP the - * hostname resolves to. This is a blocking lookup blocking for - * a maximum of one second before it times out, using the DNS - * server specified in the configuration file. + * It can only bind to IP addresses, if you wish to bind to hostnames + * you should first resolve them using class 'Resolver'. */ bool BindSocket(int sockfd, insp_sockaddr client, insp_sockaddr server, int port, char* addr) { memset(&server,0,sizeof(server)); insp_inaddr addy; - bool resolved = false; - char resolved_addr[128]; if (*addr == '*') *addr = 0; + + if ((*addr) && (inet_aton(addr,&addy) < 1)) + { + log(DEBUG,"Invalid IP '%s' given to BindSocket()", addr); + return false;; + } + #ifdef IPV6 server.sin6_family = AF_FAMILY; #else -- cgit v1.2.3