commit 06baaa8: [Minor] Another try to fix shifting
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri Jan 17 15:07:07 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-01-17 15:00:54 +0000
URL: https://github.com/rspamd/rspamd/commit/06baaa8ff24f1b74b4962e1f71cddf3946b92c2a (HEAD -> master)
[Minor] Another try to fix shifting
---
src/libserver/url.c | 6 +++---
test/lua/unit/url.lua | 3 +++
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/libserver/url.c b/src/libserver/url.c
index 648e0e103..de895299b 100644
--- a/src/libserver/url.c
+++ b/src/libserver/url.c
@@ -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);
diff --git a/test/lua/unit/url.lua b/test/lua/unit/url.lua
index 3c56713d2..92709b365 100644
--- a/test/lua/unit/url.lua
+++ b/test/lua/unit/url.lua
@@ -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',
More information about the Commits
mailing list