Commits

Anonymous committed 1f869bc

Allow / in spoofed hosts

Comments (0)

Files changed (3)

modules/m_chghost.c

 clean_host(const char *host)
 {
 	int len = 0;
+	const char *last_slash = 0;
 	
 	if (*host == '\0' || *host == ':')
 		return 0;
 
 		if(!IsHostChar(*host))
 			return 0;
+		if(*host == '/')
+			last_slash = host;
 	}
 
 	if(len > HOSTLEN)
 		return 0;
 
+	if(last_slash && IsDigit(last_slash[1]))
+		return 0;
+
 	return 1;
 }
 
 /* , */ PRINT_C | NONEOS_C,
 /* - */ PRINT_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
 /* . */ PRINT_C | KWILD_C | CHAN_C | NONEOS_C | USER_C | HOST_C | SERV_C,
-/* / */ PRINT_C | CHAN_C | NONEOS_C,
+/* / */ PRINT_C | CHAN_C | NONEOS_C | HOST_C,
 /* 0 */ PRINT_C | DIGIT_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
 /* 1 */ PRINT_C | DIGIT_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
 /* 2 */ PRINT_C | DIGIT_C | NICK_C | CHAN_C | NONEOS_C | USER_C | HOST_C,
 int
 valid_hostname(const char *hostname)
 {
-	const char *p = hostname;
+	const char *p = hostname, *last_slash = 0;
 	int found_sep = 0;
 
 	s_assert(NULL != p);
 	if(hostname == NULL)
 		return NO;
 
-	if('.' == *p || ':' == *p)
+	if('.' == *p || ':' == *p || '/' == *p)
 		return NO;
 
 	while (*p)
 			return NO;
                 if(*p == '.' || *p == ':')
   			found_sep++;
+		else if(*p == '/')
+		{
+			found_sep++;
+			last_slash = p;
+		}
 		p++;
 	}
 
 	if(found_sep == 0)
-		return(NO);
+		return NO;
 
-	return (YES);
+	if(last_slash && IsDigit(last_slash[1]))
+		return NO;
+
+	return YES;
 }
 
 /* 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.