From ef7bc9e22e733927f0c87fe423033844c08e368a Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 2 Dec 2016 12:59:20 +0000 Subject: [PATCH] [Fix] Fix length calculations for url encoded urls --- src/libserver/url.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libserver/url.c b/src/libserver/url.c index cc6cfbb3a..5041a71b2 100644 --- a/src/libserver/url.c +++ b/src/libserver/url.c @@ -770,7 +770,6 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len, if (p - c == 0) { goto out; } - SET_U (u, UF_USERINFO); st = parse_password_start; } else if (t == '@') { @@ -789,6 +788,7 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len, case parse_password_start: if (t == '@') { /* Empty password */ + SET_U (u, UF_USERINFO); st = parse_at; } else { @@ -800,6 +800,7 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len, case parse_password: if (t == '@') { /* XXX: password is not stored */ + SET_U (u, UF_USERINFO); st = parse_at; } else if (!g_ascii_isgraph (t)) { @@ -1328,6 +1329,7 @@ rspamd_url_shift (struct rspamd_url *uri, gsize nlen, uri->protocollen -= shift; memmove (uri->string + uri->protocollen, uri->string + old_shift, uri->urllen - uri->protocollen); + uri->urllen -= shift; break; case UF_HOST: if (nlen >= uri->hostlen) { @@ -1341,6 +1343,7 @@ rspamd_url_shift (struct rspamd_url *uri, gsize nlen, uri->hostlen -= shift; memmove (uri->host + uri->hostlen, uri->host + old_shift, uri->datalen + uri->querylen + uri->fragmentlen); + uri->urllen -= shift; break; case UF_PATH: if (nlen >= uri->datalen) { @@ -1354,6 +1357,7 @@ rspamd_url_shift (struct rspamd_url *uri, gsize nlen, uri->datalen -= shift; memmove (uri->data + uri->datalen, uri->data + old_shift, uri->querylen + uri->fragmentlen); + uri->urllen -= shift; break; case UF_QUERY: if (nlen >= uri->querylen) { @@ -1367,6 +1371,7 @@ rspamd_url_shift (struct rspamd_url *uri, gsize nlen, uri->querylen -= shift; memmove (uri->query + uri->querylen, uri->query + old_shift, uri->fragmentlen); + uri->urllen -= shift; break; case UF_FRAGMENT: if (nlen >= uri->fragmentlen) { @@ -1377,6 +1382,7 @@ rspamd_url_shift (struct rspamd_url *uri, gsize nlen, } uri->fragmentlen -= shift; + uri->urllen -= shift; break; default: break; -- 2.39.5