]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Fix TLD detection.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 15 Apr 2015 16:14:31 +0000 (17:14 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 15 Apr 2015 16:14:31 +0000 (17:14 +0100)
src/libserver/url.c

index 19e056c7a89024abba84adede9adf42ebc6000d1..c31a727c7a3dd1c0da7073a046543e84c8119f60 100644 (file)
@@ -894,16 +894,17 @@ rspamd_tld_trie_callback (int strnum, int textpos, void *context)
                ndots = 2;
        }
 
-       pos = url->host + textpos;
+       pos = url->host + textpos - pat->len;
        start = url->host;
 
-       if (*pos != '.' || pos + pat->len != url->host + url->hostlen) {
+       if (*pos != '.' || textpos != (gint)url->hostlen) {
                /* Something weird has been found */
                return 0;
        }
 
        /* Now we need to find top level domain */
        p = pos - 1;
+       pos = start;
        while (p >= start && ndots > 0) {
                if (*p == '.') {
                        ndots --;
@@ -913,7 +914,7 @@ rspamd_tld_trie_callback (int strnum, int textpos, void *context)
                p --;
        }
 
-       if (ndots == 0) {
+       if (ndots == 0 || p == start - 1) {
                url->tld = (gchar *)pos;
                url->tldlen = url->host + url->hostlen - pos;
        }