From: hno <> Date: Wed, 3 May 2000 02:22:54 +0000 (+0000) Subject: hno squid-2.3.DEVEL3.aclDomainCompare-2.patch X-Git-Tag: SQUID_3_0_PRE1~2011 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aca95addfb05c09933a6477e849432f0292cac4b;p=thirdparty%2Fsquid.git hno squid-2.3.DEVEL3.aclDomainCompare-2.patch 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. --- diff --git a/ChangeLog b/ChangeLog index f5e765de0d..6bc0136dbe 100644 --- 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 (): diff --git a/src/acl.cc b/src/acl.cc index 3c48300bd6..f992cc1ab9 100644 --- a/src/acl.cc +++ b/src/acl.cc @@ -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 */ diff --git a/src/url.cc b/src/url.cc index dc7d2f7396..bb781bfa00 100644 --- a/src/url.cc +++ b/src/url.cc @@ -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); /*