Allow / in spoofed hosts

This commit is contained in:
Stephen Bennett 2009-04-20 08:37:13 -05:00
parent cb9345dcd1
commit 59bb80930d
3 changed files with 19 additions and 5 deletions

View File

@ -57,6 +57,7 @@ static int
clean_host(const char *host)
{
int len = 0;
const char *last_slash = 0;
if (*host == '\0' || *host == ':')
return 0;
@ -67,11 +68,16 @@ clean_host(const char *host)
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;
}

View File

@ -702,7 +702,7 @@ const unsigned int CharAttrs[] = {
/* , */ 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,

View File

@ -712,7 +712,7 @@ introduce_client(struct Client *client_p, struct Client *source_p, struct User *
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);
@ -720,7 +720,7 @@ valid_hostname(const char *hostname)
if(hostname == NULL)
return NO;
if('.' == *p || ':' == *p)
if('.' == *p || ':' == *p || '/' == *p)
return NO;
while (*p)
@ -729,13 +729,21 @@ valid_hostname(const char *hostname)
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;
}
/*