]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix core dump when cannot extract tld in href url
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 22 Jan 2019 16:46:42 +0000 (16:46 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 22 Jan 2019 16:46:42 +0000 (16:46 +0000)
src/libserver/url.c

index 3a08ec74805264d9bb3536d332bbda8b9243c95e..018ab78c327d676add5e7cd0635a446f2bc45363 100644 (file)
@@ -1794,10 +1794,17 @@ rspamd_url_parse (struct rspamd_url *uri,
                                uri->host, uri->hostlen,
                                rspamd_tld_trie_callback, uri, NULL);
 
-       if (!(parse_flags & RSPAMD_URL_PARSE_HREF) && uri->tldlen == 0) {
-               /* Ignore URL's without TLD if it is not a numeric URL */
-               if (!rspamd_url_is_ip (uri, pool)) {
-                       return URI_ERRNO_TLD_MISSING;
+       if (uri->tldlen == 0) {
+               if (!(parse_flags & RSPAMD_URL_PARSE_HREF)) {
+                       /* Ignore URL's without TLD if it is not a numeric URL */
+                       if (!rspamd_url_is_ip (uri, pool)) {
+                               return URI_ERRNO_TLD_MISSING;
+                       }
+               }
+               else {
+                       /* Assume tld equal to host */
+                       uri->tld = uri->host;
+                       uri->tldlen = uri->hostlen;
                }
        }