diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-02 12:50:41 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-02 12:50:41 +0000 |
commit | 5b02b8768dd6066e2083987703951baa50c96e62 (patch) | |
tree | 075c513d66cc297504cd38623d27a995889ae6e8 | |
parent | 1d6b72a5ba80b7f56f20b67b92677ffba3994991 (diff) |
Check for invalid ip's being bound to
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4638 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/socket.cpp | 16 |
1 files 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 |