? src/modules/Makefile
? src/modules/callerid.c
? src/modules/callerid.tar.gz
? src/modules/m_pass.c.Inet_ia2p_fix
? src/modules/testchanmodehook.c
Index: src/modules/m_pass.c
===================================================================
RCS file: /cvs/unreal/src/modules/Attic/m_pass.c,v
retrieving revision 1.1.2.2.2.7
diff -u -b -B -r1.1.2.2.2.7 m_pass.c
--- src/modules/m_pass.c	19 Sep 2007 08:46:45 -0000	1.1.2.2.2.7
+++ src/modules/m_pass.c	27 May 2010 03:15:49 -0000
@@ -148,7 +148,7 @@
 int docgiirc(aClient *cptr, char *ip, char *host)
 {
 #ifdef INET6
-char ipbuf[64], crap[32];
+	char ipbuf[64];
 #endif
 
 	if (IsCGIIRC(cptr))
@@ -157,18 +157,20 @@
 	if (host && !strcmp(ip, host))
 		host = NULL; /* host did not resolve, make it NULL */
 
-	/* STEP 1: Update cptr->ip */
-#ifdef INET6
-	/* Transform ipv4 to ::ffff:ipv4 if needed */
-	if (inet_pton(AF_INET, ip, crap) != 0)
+	/* STEP 1: Update cptr->ip
+	   inet_pton() returns 1 on success, 0 on bad input, -1 on bad AF */
+	if(inet_pton(AFINET, ip, &cptr->ip) != 1)
 	{
+#ifndef INET6
+		/* then we have an invalid IP */
+		return exit_client(cptr, cptr, &me, "Invalid IP address");
+#else
+		/* The address may be IPv4. We have to try ::ffff:ipv4 */
 		snprintf(ipbuf, sizeof(ipbuf), "::ffff:%s", ip);
-		ip = ipbuf;
-	}
-#endif
-
-	if (inet_pton(AFINET, ip, &cptr->ip) <= 0)
+		if(inet_pton(AFINET, ipbuf, &cptr->ip) != 1)
 		return exit_client(cptr, cptr, &me, "Invalid IP address");
+#endif
+	}
 
 	/* STEP 2: Update GetIP() */
 	if (cptr->user)
@@ -190,8 +192,11 @@
 	if (host)
 		cptr->hostp = unreal_create_hostent(host, &cptr->ip);
 
-	/* STEP 4: Update sockhost */		
-	strlcpy(cptr->sockhost, ip, sizeof(cptr->sockhost));
+	/* STEP 4: Update sockhost
+	   Make sure that if this is an IPv4 address, it is _not_ prefixed with
+	   "::ffff:".
+	 */		
+	strlcpy(cptr->sockhost, Inet_ia2p(&cptr->ip), sizeof(cptr->sockhost));
 
 	SetCGIIRC(cptr);
 
