diff options
author | Jeroen van Bemmel <jvb127@gmail.com> | 2012-07-12 11:23:28 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@redhat.com> | 2012-07-12 11:31:48 +0530 |
commit | 7b6e99be77c24a79cb07416d81796b45176923c6 (patch) | |
tree | ec6fdfbc4df5a1dec8305ff8d9cd75a6e0d0608f /sysdeps/posix/getaddrinfo.c | |
parent | a766fb45a3473c416df010d614287012f7a00838 (diff) | |
download | glibc-7b6e99be77c24a79cb07416d81796b45176923c6.tar glibc-7b6e99be77c24a79cb07416d81796b45176923c6.tar.gz glibc-7b6e99be77c24a79cb07416d81796b45176923c6.tar.bz2 glibc-7b6e99be77c24a79cb07416d81796b45176923c6.zip |
Avoid duplicate DNS requests if answer is longer than a implementation
limit
[BZ #14307]
* sysdeps/posix/getaddrinfo.c (gaih_inet): Increase the size of
the temporary buffer used to invoke __gethostbyname2_r,
__gethostbyaddr_r and gethostbyname4_r to make room for struct
host_data / struct gaih_addrtuple.
* resolv/nss_dns/dns-host.c (global scope): Move definition of
implementation constants MAX_NR_ALIASES and MAX_NR_ADDRS to
header file nss/nsswitch.h.
* nss/nsswitch.h (global scope): Add definition of implementation
constants MAX_NR_ALIASES and MAX_NR_ADDRS (moved from
resolv/nss_dns/dns-host.c).
Diffstat (limited to 'sysdeps/posix/getaddrinfo.c')
-rw-r--r-- | sysdeps/posix/getaddrinfo.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index 2eca2ae0e4..78a2474b10 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -568,7 +568,9 @@ gaih_inet (const char *name, const struct gaih_service *service, IPv6 scope ids. */ if (req->ai_family == AF_INET) { - size_t tmpbuflen = 512; + /* Allocate additional room for struct host_data. */ + size_t tmpbuflen = (512 + MAX_NR_ALIASES * sizeof(char*) + + 16 * sizeof(char)); assert (tmpbuf == NULL); tmpbuf = alloca_account (tmpbuflen, alloca_used); int rc; @@ -811,7 +813,7 @@ gaih_inet (const char *name, const struct gaih_service *service, old_res_options = _res.options; _res.options &= ~RES_USE_INET6; - size_t tmpbuflen = 1024; + size_t tmpbuflen = 1024 + sizeof(struct gaih_addrtuple); malloc_tmpbuf = !__libc_use_alloca (alloca_used + tmpbuflen); assert (tmpbuf == NULL); if (!malloc_tmpbuf) @@ -1113,7 +1115,9 @@ gaih_inet (const char *name, const struct gaih_service *service, struct hostent *h = NULL; int herrno; struct hostent th; - size_t tmpbuf2len = 512; + /* Add room for struct host_data. */ + size_t tmpbuf2len = (512 + (MAX_NR_ALIASES+MAX_NR_ADDRS+1) + * sizeof(char*) + 16 * sizeof(char)); do { |