Curl_ipv4_resolve_r: only set AI_CANONNAME when needed
authorDaniel Stenberg <daniel@haxx.se>
Thu, 15 Apr 2010 11:04:01 +0000 (13:04 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 15 Apr 2010 11:04:01 +0000 (13:04 +0200)
As reported in bug report #2987196, the code for ipv6 already did
the setting of this bit correctly so we copied that logic into
the Curl_ipv4_resolve_r() function as well. KRB code is the only
code we know that might need the cannonical name so only resolve
it for such requests!

lib/hostip4.c

index fbc7d49..aa33fb9 100644 (file)
@@ -160,7 +160,12 @@ Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
       snprintf(sbuf, sizeof(sbuf), "%d", port);
       sbufptr = sbuf;
     }
-    hints.ai_flags = AI_CANONNAME;
+#ifdef HAVE_GSSAPI
+  if(conn->data->set.krb)
+    /* if krb is used, we (might) need the canonical host name */
+    hints.ai_flags |= AI_CANONNAME;
+#endif
+
     (void)Curl_getaddrinfo_ex(hostname, sbufptr, &hints, &ai);
 
 #elif defined(HAVE_GETHOSTBYNAME_R)