forked from pool/glibc
78 lines
2.8 KiB
Diff
78 lines
2.8 KiB
Diff
|
2012-07-02 Jeroen van Bemmel <jvb127@gmail.com>
|
||
|
|
||
|
[BZ #14307]
|
||
|
[BZ #13904]
|
||
|
* 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).
|
||
|
|
||
|
diff --git glibc/nss/nsswitch.h glibc/nss/nsswitch.h
|
||
|
index 90e208b..8965819 100644
|
||
|
--- glibc/nss/nsswitch.h
|
||
|
+++ glibc/nss/nsswitch.h
|
||
|
@@ -198,4 +198,8 @@ extern int __nss_hostname_digits_dots (const char *name,
|
||
|
int *h_errnop);
|
||
|
libc_hidden_proto (__nss_hostname_digits_dots)
|
||
|
|
||
|
+/* Maximum number of aliases we allow. */
|
||
|
+#define MAX_NR_ALIASES 48
|
||
|
+#define MAX_NR_ADDRS 48
|
||
|
+
|
||
|
#endif /* nsswitch.h */
|
||
|
diff --git glibc/resolv/nss_dns/dns-host.c glibc/resolv/nss_dns/dns-host.c
|
||
|
index a924d40..6b62c05 100644
|
||
|
--- glibc/resolv/nss_dns/dns-host.c
|
||
|
+++ glibc/resolv/nss_dns/dns-host.c
|
||
|
@@ -88,10 +88,6 @@
|
||
|
|
||
|
#define RESOLVSORT
|
||
|
|
||
|
-/* Maximum number of aliases we allow. */
|
||
|
-#define MAX_NR_ALIASES 48
|
||
|
-#define MAX_NR_ADDRS 48
|
||
|
-
|
||
|
#if PACKETSZ > 65536
|
||
|
# define MAXPACKET PACKETSZ
|
||
|
#else
|
||
|
diff --git glibc/sysdeps/posix/getaddrinfo.c glibc/sysdeps/posix/getaddrinfo.c
|
||
|
index 2eca2ae..efb0423 100644
|
||
|
--- glibc/sysdeps/posix/getaddrinfo.c
|
||
|
+++ glibc/sysdeps/posix/getaddrinfo.c
|
||
|
@@ -568,7 +568,8 @@ 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 in getanswer_r */
|
||
|
+ 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 +812,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 +1114,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 in resolv/nss_dns/dns-host.c */
|
||
|
+ size_t tmpbuf2len = 512 + (MAX_NR_ALIASES+MAX_NR_ADDRS+1)*sizeof(char*)
|
||
|
+ + 16 * sizeof(char);
|
||
|
|
||
|
do
|
||
|
{
|