]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Avoid one extra byte writing
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 31 Jul 2018 14:48:24 +0000 (15:48 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 31 Jul 2018 14:48:24 +0000 (15:48 +0100)
src/libserver/url.c
test/lua/unit/url.lua

index 019a4ff3622ff99f43c76dd8d68555c506106940..653cc3570665ed21f034d7429868cd206d340ba5 100644 (file)
@@ -1652,7 +1652,7 @@ rspamd_url_parse (struct rspamd_url *uri, gchar *uristring, gsize len,
                memcpy (uri->string + u.field_data[UF_SCHEMA].len, "://", 3);
                rspamd_strlcpy (uri->string + u.field_data[UF_SCHEMA].len + 3,
                        p + u.field_data[UF_SCHEMA].len + 1,
-                               len - 1 - u.field_data[UF_SCHEMA].len);
+                               len - 2 - u.field_data[UF_SCHEMA].len);
                /* Compensate slashes added */
                for (i = UF_SCHEMA + 1; i < UF_MAX; i++) {
                        if (u.field_set & (1 << i)) {
index ccde222f878dd9f850f639737436d9c074dc2fa4..902744c2ee74d9beb8803e82dd0c0de947578183 100644 (file)
@@ -95,6 +95,9 @@ context("URL check functions", function()
     {"http://twitter.com#test", true, {
       host = 'twitter.com', fragment = 'test'
     }},
+    {"http:www.twitter.com#test", true, {
+      host = 'www.twitter.com', fragment = 'test'
+    }},
   }
 
   -- Some cases from https://code.google.com/p/google-url/source/browse/trunk/src/url_canon_unittest.cc