From: Timo Sirainen Date: Mon, 19 Oct 2015 11:05:26 +0000 (+0300) Subject: lib: net_gethostbyname() now supports [ipv6] style bracketed addresses. X-Git-Tag: 2.2.20.rc1~140 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a03a29b0b12b9a071995a7e94e74c46c993d5013;p=thirdparty%2Fdovecot%2Fcore.git lib: net_gethostbyname() now supports [ipv6] style bracketed addresses. --- diff --git a/src/lib/net.c b/src/lib/net.c index bb4eff1a44..f998cb9512 100644 --- a/src/lib/net.c +++ b/src/lib/net.c @@ -628,6 +628,7 @@ int net_gethostbyname(const char *addr, struct ip_addr **ips, #ifdef HAVE_IPV6 union sockaddr_union *so; struct addrinfo hints, *ai, *origai; + struct ip_addr ip; int host_error; #else struct hostent *hp; @@ -638,6 +639,14 @@ int net_gethostbyname(const char *addr, struct ip_addr **ips, *ips_count = 0; #ifdef HAVE_IPV6 + /* support [ipv6] style addresses here so they work globally */ + if (addr[0] == '[' && net_addr2ip(addr, &ip) == 0) { + *ips_count = 1; + *ips = t_new(struct ip_addr, 1); + **ips = ip; + return 0; + } + memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_socktype = SOCK_STREAM;