]> granicus.if.org Git - pdns/commitdiff
properly detect getaddrinfo error condition from return code (hint, it might not...
authorBert Hubert <bert.hubert@netherlabs.nl>
Sun, 10 Oct 2010 19:23:35 +0000 (19:23 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sun, 10 Oct 2010 19:23:35 +0000 (19:23 +0000)
Have not solved that problem though..

git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1727 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/misc.cc

index 692b5fbb002cbefed22d01456b0f7abc10c8417d..61f8561a64dd0f2d21b695450bb529e5eee390cb 100644 (file)
@@ -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 '"<<addr<<"': ";
+    if(error==EAI_SYSTEM)
+      cerr<<strerror(errno)<<endl;
+    else
+      cerr<<gai_strerror(error)<<endl;
+    */
     return -1;
   }
   
-  memcpy(ret, res->ai_addr, sizeof(*ret));
+  memcpy(ret, res->ai_addr, res->ai_addrlen);
   
   freeaddrinfo(res);
   return 0;