]>
Commit | Line | Data |
---|---|---|
12788f63 MT |
1 | 2011-06-28 Andreas Schwab <schwab@redhat.com> |
2 | ||
3 | * sysdeps/posix/getaddrinfo.c (gaih_inet): Don't use gethostbyaddr | |
4 | to determine canonical name. | |
5 | ||
6 | 2011-06-22 Andreas Schwab <schwab@redhat.com> | |
7 | ||
8 | * sysdeps/posix/getaddrinfo.c (gaih_inet): Fix last change. | |
9 | ||
10 | 2011-06-21 Ulrich Drepper <drepper@gmail.com> | |
11 | ||
12 | [BZ #12885] | |
13 | * sysdeps/posix/getaddrinfo.c (gaih_inet): When looking up only IPv6 | |
14 | addresses using gethostbyname4_r ignore IPv4 addresses. | |
15 | ||
16 | Index: glibc-2.12-2-gc4ccff1/sysdeps/posix/getaddrinfo.c | |
17 | =================================================================== | |
18 | --- glibc-2.12-2-gc4ccff1.orig/sysdeps/posix/getaddrinfo.c | |
19 | +++ glibc-2.12-2-gc4ccff1/sysdeps/posix/getaddrinfo.c | |
20 | @@ -512,10 +512,11 @@ gaih_inet (const char *name, const struc | |
21 | ||
22 | /* If we do not have to look for IPv4 and IPv6 together, use | |
23 | the simple, old functions. */ | |
24 | - if (req->ai_family == AF_INET | |
25 | - || (req->ai_family == AF_INET6 | |
26 | - && ((req->ai_flags & AI_V4MAPPED) == 0 | |
27 | - || (req->ai_flags & AI_ALL) == 0))) | |
28 | + if ((req->ai_family == AF_INET | |
29 | + || (req->ai_family == AF_INET6 | |
30 | + && ((req->ai_flags & AI_V4MAPPED) == 0 | |
31 | + || (req->ai_flags & AI_ALL) == 0))) | |
32 | + && (req->ai_flags & AI_CANONNAME) == 0) | |
33 | { | |
34 | int family = req->ai_family; | |
35 | size_t tmpbuflen = 512; | |
36 | @@ -731,16 +732,44 @@ gaih_inet (const char *name, const struc | |
37 | tmpbuflen, 2 * tmpbuflen); | |
38 | } | |
39 | ||
40 | - no_inet6_data = no_data; | |
41 | - | |
42 | if (status == NSS_STATUS_SUCCESS) | |
43 | { | |
44 | + assert (!no_data); | |
45 | + no_data = 1; | |
46 | + | |
47 | if ((req->ai_flags & AI_CANONNAME) != 0 && canon == NULL) | |
48 | canon = (*pat)->name; | |
49 | ||
50 | while (*pat != NULL) | |
51 | - pat = &((*pat)->next); | |
52 | + { | |
53 | + if ((*pat)->family == AF_INET | |
54 | + && req->ai_family == AF_INET6 | |
55 | + && (req->ai_flags & AI_V4MAPPED) != 0) | |
56 | + { | |
57 | + uint32_t *pataddr = (*pat)->addr; | |
58 | + (*pat)->family = AF_INET6; | |
59 | + pataddr[3] = pataddr[0]; | |
60 | + pataddr[2] = htonl (0xffff); | |
61 | + pataddr[1] = 0; | |
62 | + pataddr[0] = 0; | |
63 | + pat = &((*pat)->next); | |
64 | + no_data = 0; | |
65 | + } | |
66 | + else if (req->ai_family == AF_UNSPEC | |
67 | + || (*pat)->family == req->ai_family) | |
68 | + { | |
69 | + pat = &((*pat)->next); | |
70 | + | |
71 | + no_data = 0; | |
72 | + if (req->ai_family == AF_INET6) | |
73 | + got_ipv6 = true; | |
74 | + } | |
75 | + else | |
76 | + *pat = ((*pat)->next); | |
77 | + } | |
78 | } | |
79 | + | |
80 | + no_inet6_data = no_data; | |
81 | } | |
82 | else | |
83 | { | |
84 | @@ -905,39 +934,9 @@ gaih_inet (const char *name, const struc | |
85 | { | |
86 | if (canon == NULL) | |
87 | { | |
88 | - struct hostent *h = NULL; | |
89 | - int herrno; | |
90 | - struct hostent th; | |
91 | - size_t tmpbuflen = 512; | |
92 | - char *tmpbuf = NULL; | |
93 | - | |
94 | - do | |
95 | - { | |
96 | - tmpbuf = extend_alloca (tmpbuf, tmpbuflen, tmpbuflen * 2); | |
97 | - rc = __gethostbyaddr_r (at2->addr, | |
98 | - ((at2->family == AF_INET6) | |
99 | - ? sizeof (struct in6_addr) | |
100 | - : sizeof (struct in_addr)), | |
101 | - at2->family, &th, tmpbuf, | |
102 | - tmpbuflen, &h, &herrno); | |
103 | - } | |
104 | - while (rc == ERANGE && herrno == NETDB_INTERNAL); | |
105 | - | |
106 | - if (rc != 0 && herrno == NETDB_INTERNAL) | |
107 | - { | |
108 | - __set_h_errno (herrno); | |
109 | - return -EAI_SYSTEM; | |
110 | - } | |
111 | - | |
112 | - if (h != NULL) | |
113 | - canon = h->h_name; | |
114 | - else | |
115 | - { | |
116 | - assert (orig_name != NULL); | |
117 | - /* If the canonical name cannot be determined, use | |
118 | - the passed in string. */ | |
119 | - canon = orig_name; | |
120 | - } | |
121 | + /* If the canonical name cannot be determined, use | |
122 | + the passed in string. */ | |
123 | + canon = orig_name; | |
124 | } | |
125 | ||
126 | #ifdef HAVE_LIBIDN |