]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/resolve.c
[Resolver]: Use dotted-decimal IP address if hostname is >= 64
[ngircd-alex.git] / src / ngircd / resolve.c
index ec993037cb6c6badf96b54395edfee9bd605aa35..1bd7e293127a8a59ba35eef65feacd4b70cc7503 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: resolve.c,v 1.25 2006/08/12 11:54:23 fw Exp $";
+static char UNUSED id[] = "$Id: resolve.c,v 1.28 2008/01/02 11:03:29 fw Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -24,7 +24,6 @@ static char UNUSED id[] = "$Id: resolve.c,v 1.25 2006/08/12 11:54:23 fw Exp $";
 #include <unistd.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
-#include <arpa/inet.h>
 #include <netdb.h>
 
 #ifdef IDENTAUTH
@@ -36,6 +35,7 @@ static char UNUSED id[] = "$Id: resolve.c,v 1.25 2006/08/12 11:54:23 fw Exp $";
 #include "conn.h"
 #include "defines.h"
 #include "log.h"
+#include "tool.h"
 
 #include "exp.h"
 #include "resolve.h"
@@ -153,8 +153,8 @@ Do_ResolveAddr( struct sockaddr_in *Addr, int identsock, int w_fd )
        /* Resolver sub-process: resolve IP address and write result into
         * pipe to parent. */
 
-       char hostname[HOST_LEN];
-       char ipstr[HOST_LEN];
+       char hostname[CLIENT_HOST_LEN];
+       char ipstr[CLIENT_HOST_LEN];
        struct hostent *h;
        size_t len;
        struct in_addr *addr;
@@ -169,7 +169,7 @@ Do_ResolveAddr( struct sockaddr_in *Addr, int identsock, int w_fd )
        Log_Resolver( LOG_DEBUG, "Now resolving %s ...", inet_ntoa( Addr->sin_addr ));
 #endif
        h = gethostbyaddr( (char *)&Addr->sin_addr, sizeof( Addr->sin_addr ), AF_INET );
-       if (!h) {
+       if (!h || strlen(h->h_name) >= sizeof(hostname)) {
 #ifdef h_errno
                Log_Resolver( LOG_WARNING, "Can't resolve address \"%s\": %s!", inet_ntoa( Addr->sin_addr ), Get_Error( h_errno ));
 #else
@@ -313,7 +313,8 @@ register_callback( RES_STAT *s, void (*cbfunc)(int, short))
                        return true;
 
        Log( LOG_CRIT, "Resolver: Could not register callback function: %s!", strerror(errno));
-       Resolve_Shutdown(s);
+       close(s->resolver_fd);
+       Resolve_Init(s);
        return false;
 }
 
@@ -333,7 +334,7 @@ Resolve_Shutdown( RES_STAT *s)
        return ret;
 }
 
-                
+
 /**
  * Read result of resolver sub-process from pipe
  */