aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/util.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-24 16:14:20 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-24 16:14:20 +0000
commit682ccd7ec312123e84b8aa1e19ff8a9c4ea1dac8 (patch)
tree92405118b0675f960210b793bee173a4dad2424e /src/libutil/util.c
parenta706d0e39b4548e52296a6a5bf49891343259c74 (diff)
downloadrspamd-682ccd7ec312123e84b8aa1e19ff8a9c4ea1dac8.tar.gz
rspamd-682ccd7ec312123e84b8aa1e19ff8a9c4ea1dac8.zip
Fix url insertion into a table
Previously, rspamd compared merely host names but urls can have different path that should also be considered
Diffstat (limited to 'src/libutil/util.c')
-rw-r--r--src/libutil/util.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c
index 6b3bcfb42..a3b89131c 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -1387,14 +1387,12 @@ rspamd_url_hash (gconstpointer u)
const struct rspamd_url *url = u;
XXH64_state_t st;
- XXH64_reset (&st, 0xdeadbabe);
+ XXH64_reset (&st, rspamd_hash_seed ());
- if (url->hostlen > 0) {
- XXH64_update (&st, url->host, url->hostlen);
- }
- if (url->userlen > 0) {
- XXH64_update (&st, url->user, url->userlen);
+ if (url->urllen > 0) {
+ XXH64_update (&st, url->string, url->urllen);
}
+
XXH64_update (&st, &url->flags, sizeof (url->flags));
return XXH64_digest (&st);
@@ -1433,11 +1431,11 @@ rspamd_urls_cmp (gconstpointer a, gconstpointer b)
const struct rspamd_url *u1 = a, *u2 = b;
int r;
- if (u1->hostlen != u2->hostlen || u1->hostlen == 0) {
+ if (u1->urllen != u2->urllen) {
return FALSE;
}
else {
- r = g_ascii_strncasecmp (u1->host, u2->host, u1->hostlen);
+ r = memcmp (u1->string, u2->string, u1->urllen);
if (r == 0 && u1->flags != u2->flags) {
/* Always insert phished urls to the tree */
return FALSE;