summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2006-04-15 17:48:47 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2006-04-15 17:48:47 +0000
commit037fb6d91d7f69f665346d3e7e1cd852bc26f4a1 (patch)
tree311773e741d6e977d86a8b87a636c61e25db220b /content
parent52bdd72c715c97911bee09055acec8ea30986599 (diff)
downloadnetsurf-037fb6d91d7f69f665346d3e7e1cd852bc26f4a1.tar.gz
netsurf-037fb6d91d7f69f665346d3e7e1cd852bc26f4a1.tar.bz2
Fix host match functions
svn path=/trunk/netsurf/; revision=2532
Diffstat (limited to 'content')
-rw-r--r--content/urldb.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/content/urldb.c b/content/urldb.c
index 96a0ee67f..090be9c90 100644
--- a/content/urldb.c
+++ b/content/urldb.c
@@ -1984,7 +1984,8 @@ int urldb_search_match_host(const struct host_part *a,
assert(a && b);
/* traverse up tree to root, comparing parts as we go. */
- for (; a && b; a = a->parent, b = b->parent)
+ for (; a && a != &db_root && b && b != &db_root;
+ a = a->parent, b = b->parent)
if ((ret = strcasecmp(a->part, b->part)) != 0)
/* They differ => return the difference here */
return ret;
@@ -1993,10 +1994,10 @@ int urldb_search_match_host(const struct host_part *a,
* a) The path lengths differ
* or b) The hosts are identical
*/
- if (a && !b)
+ if (a && a != &db_root && (!b || b == &db_root))
/* len(a) > len(b) */
return 1;
- else if (!a && b)
+ else if ((!a || a == &db_root) && b && b != &db_root)
/* len(a) < len(b) */
return -1;
@@ -2017,7 +2018,7 @@ int urldb_search_match_string(const struct host_part *a,
const char *end, *dot;
int plen, ret;
- assert(a && b);
+ assert(a && a != &db_root && b);
if (*b >= '0' && *b <= '9') {
/* IP address */
@@ -2026,7 +2027,7 @@ int urldb_search_match_string(const struct host_part *a,
end = b + strlen(b);
- while (b < end && a) {
+ while (b < end && a && a != &db_root) {
dot = strchr(b, '.');
if (!dot) {
/* last segment */
@@ -2059,7 +2060,7 @@ int urldb_search_match_string(const struct host_part *a,
if (a && a != &db_root && b >= end)
/* len(a) > len(b) */
return 1;
- else if (!a && b < end)
+ else if ((!a || a == &db_root) && b < end)
/* len(a) < len(b) */
return -1;
@@ -2080,7 +2081,7 @@ int urldb_search_match_prefix(const struct host_part *a,
const char *end, *dot;
int plen, ret;
- assert(a && b);
+ assert(a && a != &db_root && b);
if (*b >= '0' && *b <= '9') {
/* IP address */
@@ -2089,7 +2090,7 @@ int urldb_search_match_prefix(const struct host_part *a,
end = b + strlen(b);
- while (b < end && a) {
+ while (b < end && a && a != &db_root) {
dot = strchr(b, '.');
if (!dot) {
/* last segment */
@@ -2125,7 +2126,7 @@ int urldb_search_match_prefix(const struct host_part *a,
if (a && a != &db_root && b >= end)
/* len(a) > len(b) => prefix matches */
return 0;
- else if (!a && b < end)
+ else if ((!a || a == &db_root) && b < end)
/* len(a) < len(b) => prefix does not match */
return -1;