]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
hno squid-2.3.DEVEL3.aclDomainCompare-2.patch
authorhno <>
Wed, 3 May 2000 02:22:54 +0000 (02:22 +0000)
committerhno <>
Wed, 3 May 2000 02:22:54 +0000 (02:22 +0000)
Squid-2.3.DEVEL3: The last aclDomainCompare bugs squeezed

This patch fixes some remaining aclDomainCompare issues where Squid gave
more "is a subdomain of" warnings than it needed to.

ChangeLog
src/acl.cc
src/url.cc

index f5e765de0d4de93dfee50ae9bcfec24db0bcdfd6..6bc0136dbe19586487ad0b69c766adb8805cc927 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -41,6 +41,7 @@ Changes to Squid-2.4.DEVEL3 ():
        - Negatively cached DNS entries are now purged on "reload".
        - PURGE now also purges the DNS cache
        - HEAD on FTP objects no longer retreives the whole object
+       - More cleanups of the dstdomain ACL type
 
 Changes to Squid-2.4.DEVEL2 ():
 
index 3c48300bd6b56918dcd4926c03414bf3e8539587..f992cc1ab952a618347cb96117ba59dcf18577db 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: acl.cc,v 1.214 2000/05/02 19:58:13 hno Exp $
+ * $Id: acl.cc,v 1.215 2000/05/02 20:22:54 hno Exp $
  *
  * DEBUG: section 28    Access Control
  * AUTHOR: Duane Wessels
@@ -1979,37 +1979,23 @@ aclDestroyIntRange(intrange * list)
 static int
 aclDomainCompare(const void *a, const void *b)
 {
-    const char *d1 = a;
-    const char *d2 = b;
-    int l1;
-    int l2;
-    while ('.' == *d1)
-       d1++;
-    while ('.' == *d2)
-       d2++;
-    l1 = strlen(d1);
-    l2 = strlen(d2);
-    while (d1[--l1] == d2[--l2]) {
-       if ((l1 == 0) && (l2 == 0))
-           return 0;           /* d1 == d2 */
-       if (0 == l1) {
-           if ('.' == d2[l2 - 1]) {
-               debug(28, 0) ("WARNING: %s is a subdomain of %s\n", d2, d1);
-               debug(28, 0) ("WARNING: This may break Splay tree searching\n");
-               debug(28, 0) ("WARNING: You should remove '%s' from the ACL named '%s'\n", d2, AclMatchedName);
-           }
-           return -1;          /* d1 < d2 */
-       }
-       if (0 == l2) {
-           if ('.' == d1[l1 - 1]) {
-               debug(28, 0) ("WARNING: %s is a subdomain of %s\n", d1, d2);
-               debug(28, 0) ("WARNING: This may break Splay tree searching\n");
-               debug(28, 0) ("WARNING: You should remove '%s' from the ACL named '%s'\n", d1, AclMatchedName);
-           }
-           return 1;           /* d1 > d2 */
-       }
-    }
-    return (d1[l1] - d2[l2]);
+    const char *d1;
+    const char *d2;
+    int ret;
+    d1=b;
+    d2=a;
+    ret = aclHostDomainCompare(d1, d2);
+    if (ret != 0) {
+       d1=a;
+       d2=b;
+       ret = aclHostDomainCompare(d1, d2);
+    }
+    if (ret == 0) {
+       debug(28,0 ) ("WARNING: '%s' is a subdomain of '%s'\n", d1, d2);
+       debug(28, 0) ("WARNING: because of this '%s' is ignored to keep splay tree searching predictable\n", a);
+       debug(28, 0) ("WARNING: You should probably remove '%s' from the ACL named '%s'\n", d1, AclMatchedName);
+    }
+    return ret;
 }
 
 /* compare a host and a domain */
index dc7d2f7396906a223456d6cbd97b0d273aab8da8..bb781bfa00cab17024f9c863567caef24c0456f3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: url.cc,v 1.121 2000/03/06 16:23:36 wessels Exp $
+ * $Id: url.cc,v 1.122 2000/05/02 20:22:55 hno Exp $
  *
  * DEBUG: section 23    URL Parsing
  * AUTHOR: Duane Wessels
@@ -127,7 +127,7 @@ urlInitialize(void)
      * way we expect it to.
      */
     assert(0 == matchDomainName("foo.com", "foo.com"));
-    assert(0 == matchDomainName(".foo.com", "foo.com"));
+    assert(0 < matchDomainName(".foo.com", "foo.com"));
     assert(0 == matchDomainName("foo.com", ".foo.com"));
     assert(0 == matchDomainName(".foo.com", ".foo.com"));
     assert(0 == matchDomainName("x.foo.com", ".foo.com"));
@@ -140,6 +140,8 @@ urlInitialize(void)
     assert(0 < matchDomainName("zzz.com", "foo.com"));
     assert(0 > matchDomainName("aaa.com", "foo.com"));
     assert(0 == matchDomainName("FOO.com", "foo.COM"));
+    assert(0 < matchDomainName("bfoo.com", "afoo.com"));
+    assert(0 > matchDomainName("afoo.com", "bfoo.com"));
     /* more cases? */
 }
 
@@ -397,15 +399,12 @@ urlCanonicalClean(const request_t * request)
  *    HOST          DOMAIN        MATCH?
  * ------------- -------------    ------
  *    foo.com       foo.com         YES
- *   .foo.com       foo.com         YES
+ *   .foo.com       foo.com          NO
  *  x.foo.com       foo.com          NO
  *    foo.com      .foo.com         YES
  *   .foo.com      .foo.com         YES
  *  x.foo.com      .foo.com         YES
  *
- *  We strip leading dots on hosts (but not domains!) so that
- *  ".foo.com" is is always the same as "foo.com".
- *
  *  Return values:
  *     0 means the host matches the domain
  *     1 means the host is greater than the domain
@@ -417,8 +416,6 @@ matchDomainName(const char *h, const char *d)
 {
     int dl;
     int hl;
-    while ('.' == *h)
-       h++;
     hl = strlen(h);
     dl = strlen(d);
     /*