gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnurl] 49/178: cookie: case-insensitive hashing for the do


From: gnunet
Subject: [GNUnet-SVN] [gnurl] 49/178: cookie: case-insensitive hashing for the domains
Date: Wed, 23 May 2018 12:24:44 +0200

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to branch master
in repository gnurl.

commit 746479adcbd2bba06077642fefe0414ad6e1e0ea
Author: Lauri Kasanen <address@hidden>
AuthorDate: Thu Apr 5 15:55:59 2018 +0300

    cookie: case-insensitive hashing for the domains
    
    closes #2458
---
 lib/cookie.c      | 19 +++++++++++++++++--
 tests/data/test46 |  2 +-
 2 files changed, 18 insertions(+), 3 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);
 }
 
 /*
diff --git a/tests/data/test46 b/tests/data/test46
index a4bc9e4fa..fd0e666c6 100644
--- a/tests/data/test46
+++ b/tests/data/test46
@@ -74,6 +74,7 @@ Cookie: empty=; mooo2=indeed2; mooo=indeed
 # https://curl.haxx.se/docs/http-cookies.html
 # This file was generated by libcurl! Edit at your own risk.
 
+www.fake.come  FALSE   /       FALSE   2022144953      cookiecliente   si
 domain..tld    FALSE   /       FALSE   1739150993      mooo    indeed
 #HttpOnly_domain..tld  FALSE   /want   FALSE   1739150993      mooo2   indeed2
 domain..tld    FALSE   /want   FALSE   0       empty   
@@ -82,7 +83,6 @@ domain..tld   FALSE   /       FALSE   0       ckySession      
temporary
 domain..tld    FALSE   /       FALSE   0       ASPSESSIONIDQGGQQSJJ    
GKNBDIFAAOFDPDAIEAKDIBKE
 domain..tld    FALSE   /       FALSE   0       justaname       
 domain..tld    FALSE   /want/  FALSE   0       simplyhuge      
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
 [...]
-www.fake.come  FALSE   /       FALSE   2022144953      cookiecliente   si
 www.loser.com  FALSE   /       FALSE   2139150993      UID     99
 </file>
 </verify>

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]