diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-02-07 13:56:20 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-02-07 13:56:20 +0000 |
commit | d26d21a6699e61feb062dabed545630be1b591f0 (patch) | |
tree | c6eba9bfc81456a22bff0acdf8bb3b7337f7325c | |
parent | f66cd95dcc349044bd989ee289e8f78a406e404d (diff) | |
download | rspamd-d26d21a6699e61feb062dabed545630be1b591f0.tar.gz rspamd-d26d21a6699e61feb062dabed545630be1b591f0.zip |
[Minor] Allow to process IPv6 addresses started with `IPv6:`
-rw-r--r-- | src/libutil/addr.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libutil/addr.c b/src/libutil/addr.c index 68dcb4e8e..022a94559 100644 --- a/src/libutil/addr.c +++ b/src/libutil/addr.c @@ -721,6 +721,7 @@ rspamd_parse_inet_address_common (rspamd_inet_addr_t **target, } if (src[0] == '[') { + const gchar *ip_start; /* Ipv6 address in format [::1]:port or just [::1] */ end = memchr (src + 1, ']', srclen - 1); @@ -734,7 +735,17 @@ rspamd_parse_inet_address_common (rspamd_inet_addr_t **target, return FALSE; } - rspamd_strlcpy (ipbuf, src + 1, iplen + 1); + if (iplen > sizeof ("IPv6:") - 1 && + g_ascii_strncasecmp (src + 1, "IPv6:", sizeof ("IPv6:") - 1) == 0) { + /* Special case, SMTP conformant IPv6 address */ + ip_start = src + 1 + sizeof ("IPv6:") - 1; + iplen -= sizeof ("IPv6:") - 1; + } + else { + ip_start = src + 1; + } + + rspamd_strlcpy (ipbuf, ip_start, iplen + 1); if (rspamd_parse_inet_address_ip6 (ipbuf, iplen, &su.s6.sin6_addr)) { |