|
|
51f0aa |
Upstream commit, fixing [BZ #15218]:
|
|
|
ce426f |
|
|
|
51f0aa |
commit b957ced8890a4438c8efe2c15e5abf4e327f25cf
|
|
|
51f0aa |
Author: Andreas Schwab <schwab@suse.de>
|
|
|
51f0aa |
Date: Tue Oct 15 10:21:13 2013 +0200
|
|
|
51f0aa |
|
|
|
51f0aa |
Don't use gethostbyaddr to determine canonical name
|
|
|
ce426f |
|
|
|
ce426f |
|
|
|
ce426f |
--- glibc-2.17-c758a686/sysdeps/posix/getaddrinfo.c
|
|
|
ce426f |
+++ glibc-2.17-c758a686/sysdeps/posix/getaddrinfo.c
|
|
|
ce426f |
@@ -565,8 +565,8 @@ gaih_inet (const char *name, const struct gaih_service *service,
|
|
|
ce426f |
|
|
|
ce426f |
/* If we do not have to look for IPv6 addresses, use
|
|
|
ce426f |
the simple, old functions, which do not support
|
|
|
ce426f |
- IPv6 scope ids. */
|
|
|
ce426f |
- if (req->ai_family == AF_INET)
|
|
|
ce426f |
+ IPv6 scope ids, nor retrieving the canonical name. */
|
|
|
ce426f |
+ if (req->ai_family == AF_INET && (req->ai_flags & AI_CANONNAME) == 0)
|
|
|
ce426f |
{
|
|
|
ce426f |
/* Allocate additional room for struct host_data. */
|
|
|
ce426f |
size_t tmpbuflen = (512 + MAX_NR_ALIASES * sizeof(char*)
|
|
|
ce426f |
@@ -1107,70 +1107,10 @@ gaih_inet (const char *name, const struct gaih_service *service,
|
|
|
ce426f |
/* Only the first entry gets the canonical name. */
|
|
|
ce426f |
if (at2 == at && (req->ai_flags & AI_CANONNAME) != 0)
|
|
|
ce426f |
{
|
|
|
ce426f |
- char *tmpbuf2 = NULL;
|
|
|
ce426f |
- bool malloc_tmpbuf2 = false;
|
|
|
ce426f |
-
|
|
|
ce426f |
if (canon == NULL)
|
|
|
ce426f |
- {
|
|
|
ce426f |
- struct hostent *h = NULL;
|
|
|
ce426f |
- int herrno;
|
|
|
ce426f |
- struct hostent th;
|
|
|
ce426f |
- /* Add room for struct host_data. */
|
|
|
ce426f |
- size_t tmpbuf2len = (512 + (MAX_NR_ALIASES+MAX_NR_ADDRS+1)
|
|
|
ce426f |
- * sizeof(char*) + 16 * sizeof(char));
|
|
|
ce426f |
-
|
|
|
ce426f |
- do
|
|
|
ce426f |
- {
|
|
|
ce426f |
- if (__libc_use_alloca (alloca_used + 2 * tmpbuf2len))
|
|
|
ce426f |
- tmpbuf2 = extend_alloca_account (tmpbuf2, tmpbuf2len,
|
|
|
ce426f |
- tmpbuf2len * 2,
|
|
|
ce426f |
- alloca_used);
|
|
|
ce426f |
- else
|
|
|
ce426f |
- {
|
|
|
ce426f |
- char *newp = realloc (malloc_tmpbuf2 ? tmpbuf2 : NULL,
|
|
|
ce426f |
- 2 * tmpbuf2len);
|
|
|
ce426f |
- if (newp == NULL)
|
|
|
ce426f |
- {
|
|
|
ce426f |
- if (malloc_tmpbuf2)
|
|
|
ce426f |
- free (tmpbuf2);
|
|
|
ce426f |
- result = -EAI_MEMORY;
|
|
|
ce426f |
- goto free_and_return;
|
|
|
ce426f |
- }
|
|
|
ce426f |
-
|
|
|
ce426f |
- tmpbuf2 = newp;
|
|
|
ce426f |
- tmpbuf2len = 2 * tmpbuf2len;
|
|
|
ce426f |
- malloc_tmpbuf2 = true;
|
|
|
ce426f |
- }
|
|
|
ce426f |
-
|
|
|
ce426f |
- rc = __gethostbyaddr_r (at2->addr,
|
|
|
ce426f |
- ((at2->family == AF_INET6)
|
|
|
ce426f |
- ? sizeof (struct in6_addr)
|
|
|
ce426f |
- : sizeof (struct in_addr)),
|
|
|
ce426f |
- at2->family, &th, tmpbuf2,
|
|
|
ce426f |
- tmpbuf2len, &h, &herrno);
|
|
|
ce426f |
- }
|
|
|
ce426f |
- while (rc == ERANGE && herrno == NETDB_INTERNAL);
|
|
|
ce426f |
-
|
|
|
ce426f |
- if (rc != 0 && herrno == NETDB_INTERNAL)
|
|
|
ce426f |
- {
|
|
|
ce426f |
- if (malloc_tmpbuf2)
|
|
|
ce426f |
- free (tmpbuf2);
|
|
|
ce426f |
-
|
|
|
ce426f |
- __set_h_errno (herrno);
|
|
|
ce426f |
- result = -EAI_SYSTEM;
|
|
|
ce426f |
- goto free_and_return;
|
|
|
ce426f |
- }
|
|
|
ce426f |
-
|
|
|
ce426f |
- if (h != NULL)
|
|
|
ce426f |
- canon = h->h_name;
|
|
|
ce426f |
- else
|
|
|
ce426f |
- {
|
|
|
ce426f |
- assert (orig_name != NULL);
|
|
|
ce426f |
- /* If the canonical name cannot be determined, use
|
|
|
ce426f |
- the passed in string. */
|
|
|
ce426f |
- canon = orig_name;
|
|
|
ce426f |
- }
|
|
|
ce426f |
- }
|
|
|
ce426f |
+ /* If the canonical name cannot be determined, use
|
|
|
ce426f |
+ the passed in string. */
|
|
|
ce426f |
+ canon = orig_name;
|
|
|
ce426f |
|
|
|
ce426f |
#ifdef HAVE_LIBIDN
|
|
|
ce426f |
if (req->ai_flags & AI_CANONIDN)
|
|
|
ce426f |
@@ -1185,9 +1125,6 @@ gaih_inet (const char *name, const struct gaih_service *service,
|
|
|
ce426f |
int rc = __idna_to_unicode_lzlz (canon, &out, idn_flags);
|
|
|
ce426f |
if (rc != IDNA_SUCCESS)
|
|
|
ce426f |
{
|
|
|
ce426f |
- if (malloc_tmpbuf2)
|
|
|
ce426f |
- free (tmpbuf2);
|
|
|
ce426f |
-
|
|
|
ce426f |
if (rc == IDNA_MALLOC_ERROR)
|
|
|
ce426f |
result = -EAI_MEMORY;
|
|
|
ce426f |
else if (rc == IDNA_DLOPEN_ERROR)
|
|
|
ce426f |
@@ -1217,17 +1154,11 @@ gaih_inet (const char *name, const struct gaih_service *service,
|
|
|
ce426f |
canon = strdup (canon);
|
|
|
ce426f |
if (canon == NULL)
|
|
|
ce426f |
{
|
|
|
ce426f |
- if (malloc_tmpbuf2)
|
|
|
ce426f |
- free (tmpbuf2);
|
|
|
ce426f |
-
|
|
|
ce426f |
result = -EAI_MEMORY;
|
|
|
ce426f |
goto free_and_return;
|
|
|
ce426f |
}
|
|
|
ce426f |
}
|
|
|
ce426f |
}
|
|
|
ce426f |
-
|
|
|
ce426f |
- if (malloc_tmpbuf2)
|
|
|
ce426f |
- free (tmpbuf2);
|
|
|
ce426f |
}
|
|
|
ce426f |
|
|
|
ce426f |
family = at2->family;
|