mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 18:22:50 +01:00
Skip cidr checking for bans with negative or too large cidrlen.
Upto some length, such bans could match the exact IP address. Obtained from: ircd-ratbox (androsyn)
This commit is contained in:
parent
3dae60ef47
commit
4dbd5e07ad
1 changed files with 7 additions and 1 deletions
|
@ -436,12 +436,15 @@ int match_cidr(const char *s1, const char *s2)
|
|||
*len++ = '\0';
|
||||
|
||||
cidrlen = atoi(len);
|
||||
if (cidrlen == 0)
|
||||
if (cidrlen <= 0)
|
||||
return 0;
|
||||
|
||||
#ifdef RB_IPV6
|
||||
if (strchr(ip, ':') && strchr(ipmask, ':'))
|
||||
{
|
||||
if (cidrlen > 128)
|
||||
return 0;
|
||||
|
||||
aftype = AF_INET6;
|
||||
ipptr = &((struct sockaddr_in6 *)&ipaddr)->sin6_addr;
|
||||
maskptr = &((struct sockaddr_in6 *)&maskaddr)->sin6_addr;
|
||||
|
@ -450,6 +453,9 @@ int match_cidr(const char *s1, const char *s2)
|
|||
#endif
|
||||
if (!strchr(ip, ':') && !strchr(ipmask, ':'))
|
||||
{
|
||||
if (cidrlen > 32)
|
||||
return 0;
|
||||
|
||||
aftype = AF_INET;
|
||||
ipptr = &((struct sockaddr_in *)&ipaddr)->sin_addr;
|
||||
maskptr = &((struct sockaddr_in *)&maskaddr)->sin_addr;
|
||||
|
|
Loading…
Reference in a new issue