]> jfr.im git - irc/UndernetIRC/gnuworld.git/commitdiff
Fix for too wide GLINE masks
authorGergo F <redacted>
Mon, 12 Nov 2018 17:06:19 +0000 (17:06 +0000)
committerGergo F <redacted>
Mon, 12 Nov 2018 17:06:19 +0000 (17:06 +0000)
libgnuworld/misc.cc
libgnuworld/misc.h
mod.ccontrol/ccontrol.cc

index 0b7f4820615785b1afef78d59b8706804b92a677..12b19d9994c9828300adadb25d4d2ee026239251 100644 (file)
@@ -368,6 +368,28 @@ bool isUserHost(const string& address)
        return true;
 }
 
+bool isAllWildcard(const string& address, bool checkfordots)
+{
+       bool allwildcard = true;
+       for (string::size_type pos = 0; pos < address.size(); pos++)
+       {
+               if ((address[pos] == '*') || (address[pos] == '?'))
+               {
+                       continue;
+               }
+               else if ((checkfordots) && (address[pos] == '.'))
+               {
+                       continue;
+               }
+               else
+               {
+                       allwildcard = false;
+                       break;
+               }
+       }
+       return allwildcard;
+}
+
 unsigned char fixToCIDR64(string& strIP)
 {
        irc_in_addr ip;
index 937d92aa2579bc87e1e53a83488b98c6c76fd549..cf9fa7f9c08e5e01bafb67a8505a2da33502f9a6 100755 (executable)
@@ -171,6 +171,8 @@ string fixAddress( const string& );
 //Check if we have !at least! a *@hostip format
 bool isUserHost( const string& );
 
+bool isAllWildcard(const string&, bool checkfordots = false);
+
 /* Truncate a > /64 IPv6 address to a /64 cidr address
  * or creates a between /32 - /64 valid cidr address
  */
index d4cc1e94c4e5eeb25c776383711b580642632b49..614e93c82ad86bb02e383b5f3c11115f8396d1b1 100644 (file)
@@ -4222,6 +4222,9 @@ int ccontrol::checkGline4(string &Host,unsigned int Len,unsigned int &Affected)
        if (ipmask_len < 120)   //(120 = 128 - 8)
                retMe |= gline::HUH_NO_HOST;  //Its too wide
 
+       if (isAllWildcard(Hostname, true))
+               retMe |=  gline::HUH_NO_HOST;
+
        if (ipmask_len < 128)
                IsWildcard = true;
 
@@ -4239,30 +4242,21 @@ int ccontrol::checkGline4(string &Host,unsigned int Len,unsigned int &Affected)
        if (Affected > gline::MFGLINE_USERS)
                retMe |= gline::FU_NEEDED_USERS; //This gline must be set with -fu flag
 
-       if(Len >  gline::MFGLINE_TIME)
+       if (Len > gline::MFGLINE_TIME)
                retMe |=  gline::FU_NEEDED_TIME;
-       if(Len >  gline::MGLINE_TIME)
+       if (Len > gline::MGLINE_TIME)
                retMe |=  gline::FORCE_NEEDED_TIME;
+
        if (IsWildcard) //we have a 'wildcard' gline
        {  //Need to check the Ident now
-               bool hasId = false;
-               for(string::size_type pos = 0; pos < Ident.size();++pos)
-               {
-                       if((Ident[pos] == '*') || (Ident[pos] == '?'))
-                       {
-                               continue;
-                       }
-                       else
-                       { //Its not */? so we have a legal ident
-                               hasId = true;
-                               break;
-                       }
-               }
-               if((hasId & (Len >  gline::MGLINE_WILD_TIME))
-                       || (!hasId & (Len >  gline::MGLINE_WILD_NOID_TIME)))
+               bool hasId = !isAllWildcard(Ident);
+               if ((hasId & (Len > gline::MGLINE_WILD_TIME))
+                       || (!hasId & (Len > gline::MGLINE_WILD_NOID_TIME)))
                {
                        retMe |=  gline::FORCE_NEEDED_WILDTIME;
                }
+               if (hasId)
+                       retMe |=  gline::HUH_NO_HOST;
        }
 
        if (getExceptions("*@" + Hostname) > 0)