]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Avoid duplicate DNS requests if answer is longer than a implementation
authorJeroen van Bemmel <jvb127@gmail.com>
Thu, 12 Jul 2012 05:53:28 +0000 (11:23 +0530)
committerSiddhesh Poyarekar <siddhesh@redhat.com>
Thu, 12 Jul 2012 06:01:48 +0000 (11:31 +0530)
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).

ChangeLog
nss/nsswitch.h
resolv/nss_dns/dns-host.c
sysdeps/posix/getaddrinfo.c

index bcda5492af43779038a2dd88e21f9f8d814ad875..db8e18787fc84845cfb35456076cb6960e61d57d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2012-07-12  Jeroen van Bemmel  <jvb127@gmail.com>
+
+       [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).
+
 2012-07-11  Andreas Jaeger  <aj@suse.de>
 
        * po/fr.po: Update from translation team.
index 90e208b2b02bb778da85dabfb3681eaaa899f777..047a9e5858f1b3de256e1a1443aff21f9d16e41d 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (C) 1996-1999,2001,2002,2003,2004,2007,2010,2011
-   Free Software Foundation, Inc.
+/* Copyright (C) 1996-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -198,4 +197,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 */
index a924d40844a5737213bf11498b1c05ee27d32816..6b62c058837b33a9a80010601beaeeca4f2323bf 100644 (file)
 
 #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
index 2eca2ae0e406474191a03634897e2ec0a11a598a..78a2474b101e9e7b9d243008b129bf91e0ef3514 100644 (file)
@@ -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
                  {