diff options
author | 2015-10-28 07:28:13 +0000 | |
---|---|---|
committer | 2015-10-28 07:28:13 +0000 | |
commit | a706cb8941ccec4b20eb4759b4bc6a2dd2f35b6c (patch) | |
tree | 1dd26bcf0419bbceb514ee93d3e0f22f88a256bc | |
parent | aliases support resolving to maildir:/path (diff) | |
download | wireguard-openbsd-a706cb8941ccec4b20eb4759b4bc6a2dd2f35b6c.tar.xz wireguard-openbsd-a706cb8941ccec4b20eb4759b4bc6a2dd2f35b6c.zip |
dns_lookup_host() needs to remove brackets and IPv6: prefix when receiving
a text representation otherwise getaddrinfo_async() will choke
ok eric@
-rw-r--r-- | usr.sbin/smtpd/dns.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/usr.sbin/smtpd/dns.c b/usr.sbin/smtpd/dns.c index 808a28ccb1c..d4dc267bb08 100644 --- a/usr.sbin/smtpd/dns.c +++ b/usr.sbin/smtpd/dns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dns.c,v 1.82 2015/10/17 13:30:47 gilles Exp $ */ +/* $OpenBSD: dns.c,v 1.83 2015/10/28 07:28:13 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@poolp.org> @@ -434,6 +434,8 @@ dns_lookup_host(struct dns_session *s, const char *host, int preference) { struct dns_lookup *lookup; struct addrinfo hints; + char hostcopy[HOST_NAME_MAX+1]; + char *p; void *as; lookup = xcalloc(1, sizeof *lookup, "dns_lookup_host"); @@ -441,6 +443,18 @@ dns_lookup_host(struct dns_session *s, const char *host, int preference) lookup->session = s; s->refcount++; + if (*host == '[') { + if (strncasecmp("[IPv6:", host, 6) == 0) + host += 6; + else + host += 1; + (void)strlcpy(hostcopy, host, sizeof hostcopy); + p = strchr(hostcopy, ']'); + if (p) + *p = 0; + host = hostcopy; + } + memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_ADDRCONFIG; hints.ai_family = PF_UNSPEC; |