about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2005-07-25 09:20:10 +0000
committerFlorian Westphal <fw@strlen.de>2005-07-25 09:20:10 +0000
commit2e794a6943a74f2ba4f3769703e3500fe9008461 (patch)
tree46e97ed36393ae0bd221f56ca992c1a4434acff8
parent1e9e16fa3b436c974915833ef71748fbcd9dd658 (diff)
downloadngircd-2e794a6943a74f2ba4f3769703e3500fe9008461.tar.gz
ngircd-2e794a6943a74f2ba4f3769703e3500fe9008461.zip
Reverse lookup now checks result by additional forward lookup
-rw-r--r--ChangeLog3
-rw-r--r--src/ngircd/resolve.c15
2 files changed, 12 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 5b83df83..57f3e65f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@
 
 
 ngIRCd CVSHEAD
+  - Reverse DNS lookup code now checks the result by doing an additional lookup.
   - Add new IO Layer
 
 ngIRCd 0.9.x
@@ -614,4 +615,4 @@ ngIRCd 0.0.1, 31.12.2001
 
 
 -- 
-$Id: ChangeLog,v 1.279 2005/07/07 18:50:23 fw Exp $
+$Id: ChangeLog,v 1.280 2005/07/25 09:20:10 fw Exp $
diff --git a/src/ngircd/resolve.c b/src/ngircd/resolve.c
index 5529f168..8e1749a3 100644
--- a/src/ngircd/resolve.c
+++ b/src/ngircd/resolve.c
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: resolve.c,v 1.14 2005/07/24 21:42:00 fw Exp $";
+static char UNUSED id[] = "$Id: resolve.c,v 1.15 2005/07/25 09:20:10 fw Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -189,12 +189,15 @@ Do_ResolveAddr( struct sockaddr_in *Addr, int w_fd )
 	struct hostent *h;
 	size_t len;
 	struct in_addr *addr;
+	char *ntoaptr;
 #ifdef IDENTAUTH
 	char *res;
 #endif
 
 	/* Resolve IP address */
+#ifdef DEBUG
 	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) {
 #ifdef h_errno
@@ -211,14 +214,16 @@ Do_ResolveAddr( struct sockaddr_in *Addr, int w_fd )
 			if (memcmp(h->h_addr, &Addr->sin_addr, sizeof (struct in_addr))) {
 				addr = (struct in_addr*) h->h_addr;
 				strlcpy(ipstr, inet_ntoa(*addr), sizeof ipstr); 
+				ntoaptr = inet_ntoa( Addr->sin_addr );
 				Log(LOG_WARNING,"Possible forgery: %s resolved to %s (which is at ip %s!)",
-								inet_ntoa( Addr->sin_addr), hostname, ipstr);
-				strlcpy( hostname, inet_ntoa( Addr->sin_addr ), sizeof( hostname ));
+										ntoaptr, hostname, ipstr);
+				strlcpy( hostname, ntoaptr, sizeof hostname);
 			}
 		} else {
+			ntoaptr = inet_ntoa( Addr->sin_addr );
 			Log(LOG_WARNING, "Possible forgery: %s resolved to %s (which has no ip address)",
-						inet_ntoa( Addr->sin_addr ), hostname);
-				strlcpy( hostname, inet_ntoa( Addr->sin_addr ), sizeof( hostname ));
+											ntoaptr, hostname);
+			strlcpy( hostname, ntoaptr, sizeof hostname);
 		}
 	}
 	Log_Resolver( LOG_DEBUG, "Ok, translated %s to \"%s\".", inet_ntoa( Addr->sin_addr ), hostname );