]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Another try to fix shifting
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 17 Jan 2020 15:00:54 +0000 (15:00 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 17 Jan 2020 15:00:54 +0000 (15:00 +0000)
src/libserver/url.c
test/lua/unit/url.lua

index 648e0e1036a2e7e186aec47378492dd4fada5e48..de895299b1d31cc950ed6fc22291d9a5dc9ff239 100644 (file)
@@ -1812,7 +1812,7 @@ rspamd_url_shift (struct rspamd_url *uri, gsize nlen,
 
                old_shift = uri->hostlen;
                uri->hostlen -= shift;
-               remain = (uri->urllen - (uri->host - uri->string)) - uri->hostlen;
+               remain = (uri->urllen - (uri->host - uri->string)) - old_shift;
                g_assert (remain >= 0);
                memmove (uri->host + uri->hostlen, uri->host + old_shift,
                                remain);
@@ -1829,7 +1829,7 @@ rspamd_url_shift (struct rspamd_url *uri, gsize nlen,
 
                old_shift = uri->datalen;
                uri->datalen -= shift;
-               remain = (uri->urllen - (uri->data - uri->string)) - uri->datalen;
+               remain = (uri->urllen - (uri->data - uri->string)) - old_shift;
                g_assert (remain >= 0);
                memmove (uri->data + uri->datalen, uri->data + old_shift,
                                remain);
@@ -1846,7 +1846,7 @@ rspamd_url_shift (struct rspamd_url *uri, gsize nlen,
 
                old_shift = uri->querylen;
                uri->querylen -= shift;
-               remain = (uri->urllen - (uri->query - uri->string)) - uri->querylen;
+               remain = (uri->urllen - (uri->query - uri->string)) - old_shift;
                g_assert (remain >= 0);
                memmove (uri->query + uri->querylen, uri->query + old_shift,
                                remain);
index 3c56713d23361fc182b305aa965ed1dfdc522696..92709b365dfea5fb9cec7e0d980ae818a283dc61 100644 (file)
@@ -56,6 +56,9 @@ context("URL check functions", function()
   end
 
   cases = {
+    {[[http://example.net/path/.]], true, {
+      host = 'example.net', path = 'path'
+    }},
     {'http://example.net/hello%20world.php?arg=x#fragment', true, {
       host = 'example.net', fragment = 'fragment', query = 'arg=x',
       path = 'hello world.php',