Fix the irregular IP ban bug harder.
authorMichael Poole <mdpoole@troilus.org>
Tue, 9 Aug 2005 03:35:15 +0000 (03:35 +0000)
committerMichael Poole <mdpoole@troilus.org>
Tue, 9 Aug 2005 03:35:15 +0000 (03:35 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1454 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd/channel.c

index 96e23aa35003eb2c213be237da6f1064f35983f4..ca229557ce19ed2e74edad687ae8e1173ae7675c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-08-08  Michael Poole <mdpoole@troilus.org>
+
+       * ircd/channel.c (find_ban): For non-IPmask bans, match the ban
+       string against the string form of the client's IP address.
+
 2005-07-16  Michael Poole <mdpoole@troilus.org>
 
        * configure.in: Apply a test for socklen_t that Reed found.
index 51d1c25340aadd43496dadaa6149df7c0e35da4e..7a9990266e5413c9b737daf7dca377bf6ac5ad9e 100644 (file)
@@ -346,12 +346,15 @@ struct Ban *find_ban(struct Client *cptr, struct Ban *banlist)
 {
   char        nu[NICKLEN + USERLEN + 2];
   char        tmphost[HOSTLEN + 1];
+  char        iphost[SOCKIPLEN + 1];
+  char       *hostmask;
   char       *sr;
   struct Ban *found;
 
   /* Build nick!user and alternate host names. */
   ircd_snprintf(0, nu, sizeof(nu), "%s!%s",
                 cli_name(cptr), cli_user(cptr)->username);
+  ircd_ntoa_r(iphost, &cli_ip(cptr));
   if (!IsAccount(cptr))
     sr = NULL;
   else if (HasHiddenHost(cptr))
@@ -376,10 +379,12 @@ struct Ban *find_ban(struct Client *cptr, struct Ban *banlist)
     if (res)
       continue;
     /* Compare host portion of ban. */
-    if (!((banlist->flags & BAN_IPMASK)
-         && ipmask_check(&cli_ip(cptr), &banlist->address, banlist->addrbits))
-        && match(banlist->banstr + banlist->nu_len + 1, cli_user(cptr)->host)
-        && !(sr && match(banlist->banstr + banlist->nu_len + 1, sr) == 0))
+    hostmask = banlist->banstr + banlist->nu_len + 1;
+    if (((banlist->flags & BAN_IPMASK)
+         ? !ipmask_check(&cli_ip(cptr), &banlist->address, banlist->addrbits)
+         : match(hostmask, iphost))
+        && match(hostmask, cli_user(cptr)->host)
+        && !(sr && match(hostmask, sr) == 0))
       continue;
     /* If an exception matches, no ban can match. */
     if (banlist->flags & BAN_EXCEPTION)