Fix glob matching against IPs
authorMichael Poole <mdpoole@troilus.org>
Sat, 16 Oct 2004 21:14:11 +0000 (21:14 +0000)
committerMichael Poole <mdpoole@troilus.org>
Sat, 16 Oct 2004 21:14:11 +0000 (21:14 +0000)
Do not require the first character in an IP glob to be a digit.  If an
IP-looking glob does not match, fall through to the other host matching
rules, in case the IP-looking glob really matches their hostname.
git-archimport-id: srvx@srvx.net--2004-srvx/srvx--devo--1.3--patch-82

ChangeLog
src/tools.c

index 0d9f1145246c3c227b875990b9d7a0146ca83be2..b577fd0375dd482f4576e471bfed0c67548ff419 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,21 @@
 # arch-tag: automatic-ChangeLog--srvx@srvx.net--2004-srvx/srvx--devo--1.3
 #
 
+2004-10-16 21:14:11 GMT        Michael Poole <mdpoole@troilus.org>     patch-82
+
+    Summary:
+      Fix glob matching against IPs
+    Revision:
+      srvx--devo--1.3--patch-82
+
+    Do not require the first character in an IP glob to be a digit.  If an
+    IP-looking glob does not match, fall through to the other host matching
+    rules, in case the IP-looking glob really matches their hostname.
+
+    modified files:
+     ChangeLog src/tools.c
+
+
 2004-09-15 04:14:14 GMT        adam <adam@gamesurge.net>       patch-81
 
     Summary:
index 53214dc56775256348582b1548debfd660db497b..26c83a9b393fbe38ebdb5a10aef48be20662b1b0 100644 (file)
@@ -334,22 +334,22 @@ user_matches_glob(struct userNode *user, const char *orig_glob, int include_nick
     if (!match_ircglob(user->ident, glob))
         return 0;
     glob = marker + 1;
-    /* Now check the host part */
-    if (isdigit(*glob) && !glob[strspn(glob, "0123456789./*?")]) {
-        /* Looks like an IP-based mask */
-        return match_ircglob(inet_ntoa(user->ip), glob);
-    } else {
-        /* The host part of the mask isn't IP-based */
-        if (IsFakeHost(user) && match_ircglob(user->fakehost, glob))
+    /* If it might be an IP glob, test that. */
+    if (!glob[strspn(glob, "0123456789./*?")]
+        && match_ircglob(inet_ntoa(user->ip), glob))
+        return 1;
+    /* Check for a fakehost match. */
+    if (IsFakeHost(user) && match_ircglob(user->fakehost, glob))
+            return 1;
+    /* Check for an account match. */
+    if (hidden_host_suffix && user->handle_info) {
+        char hidden_host[HOSTLEN+1];
+        snprintf(hidden_host, sizeof(hidden_host), "%s.%s", user->handle_info->handle, hidden_host_suffix);
+        if (match_ircglob(hidden_host, glob))
             return 1;
-        if (hidden_host_suffix && user->handle_info) {
-            char hidden_host[HOSTLEN+1];
-            snprintf(hidden_host, sizeof(hidden_host), "%s.%s", user->handle_info->handle, hidden_host_suffix);
-            if (match_ircglob(hidden_host, glob))
-                return 1;
-        }
-        return match_ircglob(user->hostname, glob);
     }
+    /* None of the above; could only be a hostname match. */
+    return match_ircglob(user->hostname, glob);
 }
 
 int