-/* $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>
{
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");
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;