aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-11-13 20:47:06 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-11-13 20:47:06 +0000
commit6c89ca62fecf0ee5d4a5da80785a11dd545edf0d (patch)
tree957a67e919e6bc433775f423589d0779a69a63a1 /src
parente64778a742265abc830c8050750fba56891bc2f8 (diff)
downloadrspamd-6c89ca62fecf0ee5d4a5da80785a11dd545edf0d.tar.gz
rspamd-6c89ca62fecf0ee5d4a5da80785a11dd545edf0d.zip
[Fix] Try harder in passing IPv6 addresses
Issue: #1916 MFH: rspamd-1.6
Diffstat (limited to 'src')
-rw-r--r--src/libserver/milter.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/libserver/milter.c b/src/libserver/milter.c
index b809b89b6..3ad567b02 100644
--- a/src/libserver/milter.c
+++ b/src/libserver/milter.c
@@ -311,6 +311,8 @@ rspamd_milter_process_command (struct rspamd_milter_session *session,
else {
guchar proto;
guint16 port;
+ gchar ip6_str[INET6_ADDRSTRLEN + 3];
+ gsize r;
/*
* Important notice: Postfix do NOT use this command to pass
@@ -373,16 +375,28 @@ rspamd_milter_process_command (struct rspamd_milter_session *session,
break;
case RSPAMD_MILTER_CONN_INET6:
- session->addr = rspamd_inet_address_new (AF_INET, NULL);
+ session->addr = rspamd_inet_address_new (AF_INET6, NULL);
if (zero - pos > sizeof ("IPv6:") &&
rspamd_lc_cmp (pos, "IPv6:",
sizeof ("IPv6:") - 1) == 0) {
/* Kill sendmail please */
pos += sizeof ("IPv6:") - 1;
+
+ if (*pos != '[') {
+ /* Add explicit braces */
+ r = rspamd_snprintf (ip6_str, sizeof (ip6_str),
+ "[%*s]", (int)(zero - pos), pos);
+ }
+ else {
+ r = rspamd_strlcpy (ip6_str, pos, sizeof (ip6_str));
+ }
+ }
+ else {
+ r = rspamd_strlcpy (ip6_str, pos, sizeof (ip6_str));
}
- if (!rspamd_parse_inet_address_ip (pos, zero - pos,
+ if (!rspamd_parse_inet_address_ip (ip6_str, r,
session->addr)) {
err = g_error_new (rspamd_milter_quark (), EINVAL,
"invalid connect command (bad IPv6)");
@@ -1367,8 +1381,14 @@ rspamd_milter_to_http (struct rspamd_milter_session *session)
}
if (session->addr) {
- rspamd_http_message_add_header (msg, IP_ADDR_HEADER,
- rspamd_inet_address_to_string (session->addr));
+ if (rspamd_inet_address_get_af (session->addr) != AF_UNIX) {
+ rspamd_http_message_add_header (msg, IP_ADDR_HEADER,
+ rspamd_inet_address_to_string_pretty (session->addr));
+ }
+ else {
+ rspamd_http_message_add_header (msg, IP_ADDR_HEADER,
+ rspamd_inet_address_to_string (session->addr));
+ }
}
rspamd_milter_macro_http (session, msg);