From: Bert Hubert Date: Sun, 10 Oct 2010 19:23:35 +0000 (+0000) Subject: properly detect getaddrinfo error condition from return code (hint, it might not... X-Git-Tag: rec-3.3.1~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f4f4f533c18ab2a3647021c3fbe7cf2930bee042;p=pdns properly detect getaddrinfo error condition from return code (hint, it might not be negative!) Discovered by Bryan Seitz, who tried to run PowerDNS on a FreeBSD installation that had *everything* related to IPv6 commented out Have not solved that problem though.. git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1727 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/misc.cc b/pdns/misc.cc index 692b5fbb0..61f8561a6 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -672,12 +672,19 @@ int makeIPv6sockaddr(const std::string& addr, struct sockaddr_in6* ret) hints.ai_family = AF_INET6; hints.ai_flags = AI_NUMERICHOST; - if(getaddrinfo(addr.c_str(), 0, &hints, &res) < 0) { - perror("getaddrinfo"); + int error; + if((error=getaddrinfo(addr.c_str(), 0, &hints, &res))) { + /* + cerr<<"Error translating IPv6 address '"<ai_addr, sizeof(*ret)); + memcpy(ret, res->ai_addr, res->ai_addrlen); freeaddrinfo(res); return 0;