summaryrefslogtreecommitdiffstats
path: root/src/libserver/url.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-04-12 11:58:28 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-04-12 11:58:28 +0100
commit78a0cb71867a61124c09e60a843e1339d303e3a4 (patch)
treeadf25a1c92fd12f85810475e2a0157b9f09ef418 /src/libserver/url.c
parent01c729e15e01db5a5353f783325c520ac069a532 (diff)
downloadrspamd-78a0cb71867a61124c09e60a843e1339d303e3a4.tar.gz
rspamd-78a0cb71867a61124c09e60a843e1339d303e3a4.zip
[Minor] Url: Fix parsing of numeric urls with a port
Diffstat (limited to 'src/libserver/url.c')
-rw-r--r--src/libserver/url.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libserver/url.c b/src/libserver/url.c
index 8183213b6..1548c4535 100644
--- a/src/libserver/url.c
+++ b/src/libserver/url.c
@@ -1715,11 +1715,16 @@ rspamd_url_regen_from_inet_addr (struct rspamd_url *uri, const void *addr, int a
slen += INET6_ADDRSTRLEN;
}
+ if (uri->flags & RSPAMD_URL_FLAG_HAS_PORT) {
+ slen += sizeof ("65535") - 1;
+ }
+
/* Allocate new string to build it from IP */
strbuf = rspamd_mempool_alloc (pool, slen + 1);
r += rspamd_snprintf (strbuf + r, slen - r, "%*s",
(gint)(uri->hostshift),
uri->string);
+
uri->hostshift = r;
uri->tldshift = r;
start_offset = strbuf + r;
@@ -1730,6 +1735,12 @@ rspamd_url_regen_from_inet_addr (struct rspamd_url *uri, const void *addr, int a
uri->flags |= RSPAMD_URL_FLAG_NUMERIC;
/* Reconstruct URL */
+ if (uri->flags & RSPAMD_URL_FLAG_HAS_PORT) {
+ p = strbuf + r;
+ start_offset = p + 1;
+ r += rspamd_snprintf (strbuf + r, slen - r, ":%ud",
+ (unsigned int)uri->port);
+ }
if (uri->datalen > 0) {
p = strbuf + r;
start_offset = p + 1;