]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(gaih_inet): If req->ai_family == AF_UNSPEC don't allow the IPv6 lookup to return...
authorUlrich Drepper <drepper@redhat.com>
Sat, 27 May 2000 08:09:40 +0000 (08:09 +0000)
committerUlrich Drepper <drepper@redhat.com>
Sat, 27 May 2000 08:09:40 +0000 (08:09 +0000)
sysdeps/posix/getaddrinfo.c

index 59e2cec1290f5d1f5af0248da90b6b7e864cae7c..45d1da22f95cd692b40b31bd8ce2ffa0e3f34266 100644 (file)
@@ -45,6 +45,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <assert.h>
 #include <errno.h>
 #include <netdb.h>
+#include <resolv.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -430,11 +431,22 @@ gaih_inet (const char *name, const struct gaih_service *service,
          struct gaih_addrtuple **pat = &at;
          int no_data = 0;
          int no_inet6_data;
+         int old_res_options = _res.options;
+
+         /* If we are looking for both IPv4 and IPv6 address we don't
+            want the lookup functions to automatically promote IPv4
+            addresses to IPv6 addresses.  Currently this is decided
+            by setting the RES_USE_INET6 bit in _res.options.  */
+         if (req->ai_family == AF_UNSPEC)
+           _res.options &= ~RES_USE_INET6;
 
          if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET6)
            gethosts (AF_INET6, struct in6_addr);
          no_inet6_data = no_data;
 
+         if (req->ai_family == AF_UNSPEC)
+           _res.options = old_res_options;
+
          if (req->ai_family == AF_UNSPEC || req->ai_family == AF_INET)
            gethosts (AF_INET, struct in_addr);