diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cookie.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/cookie.c b/lib/cookie.c index ec3b1bf9a..5aa959690 100644 --- a/lib/cookie.c +++ b/lib/cookie.c @@ -90,7 +90,6 @@ Example set of cookies: #include "urldata.h" #include "cookie.h" -#include "hash.h" #include "strtok.h" #include "sendf.h" #include "slist.h" @@ -266,6 +265,22 @@ static const char *get_top_domain(const char * const domain, size_t *outlen) } /* + * A case-insensitive hash for the cookie domains. + */ +static size_t cookie_hash_domain(const char *domain, const size_t len) +{ + const char *end = domain + len; + unsigned long h = 5381; + + while(domain < end) { + h += h << 5; + h ^= (unsigned long) Curl_raw_toupper(*domain++); + } + + return (h % COOKIE_HASH_SIZE); +} + +/* * Hash this domain. */ static size_t cookiehash(const char * const domain) @@ -277,7 +292,7 @@ static size_t cookiehash(const char * const domain) return 0; top = get_top_domain(domain, &len); - return Curl_hash_str((void *) top, len, COOKIE_HASH_SIZE); + return cookie_hash_domain(top, len); } /* |