This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.21-255-g561052a


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  561052ad35d7004a6f69c772a6a2a106e436f950 (commit)
       via  c6ee40da8b7b285a644dc22b78d8e47d2bebfae6 (commit)
       via  794a74af4da66ecde74d8e298e03b3b578a1ed33 (commit)
       via  866ba63b312fd015e1585ee46943f57187e82868 (commit)
       via  7b8399f479fb9ebaf816a49246ea5c6354a0769e (commit)
      from  da0cf658c6758d2e6d1b1b99312f66150ccc7a43 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=561052ad35d7004a6f69c772a6a2a106e436f950

commit 561052ad35d7004a6f69c772a6a2a106e436f950
Author: Florian Weimer <fweimer@redhat.com>
Date:   Wed Apr 8 20:58:58 2015 +0200

    nscd_getgr_r: Use struct scratch_buffer instead of extend_alloca
    
    The lack of alloca accounting means that the old code could run out of
    stack space if multiple retries are needed.

diff --git a/ChangeLog b/ChangeLog
index 93583af..fd79b12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,7 @@
 	* nis/nss_compat/compat-initgroups.c (_nss_compat_initgroups_dyn):
 	Rewrite to use struct scratch_buffer instead of extend_alloca.
 	* inet/getnameinfo.c (nrl_domainname, getnameinfo): Likewise.
+	* nscd/nscd_getgr_r.c (nscd_getgr_r): Likewise.
 
 2015-04-08  Joseph Myers  <joseph@codesourcery.com>
 
diff --git a/nscd/nscd_getgr_r.c b/nscd/nscd_getgr_r.c
index 7e45ee5..d08b73f 100644
--- a/nscd/nscd_getgr_r.c
+++ b/nscd/nscd_getgr_r.c
@@ -31,6 +31,7 @@
 #include <sys/un.h>
 #include <not-cancel.h>
 #include <_itoa.h>
+#include <scratch_buffer.h>
 
 #include "nscd-client.h"
 #include "nscd_proto.h"
@@ -89,7 +90,8 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
   int gc_cycle;
   int nretries = 0;
   const uint32_t *len = NULL;
-  size_t lensize = 0;
+  struct scratch_buffer lenbuf;
+  scratch_buffer_init (&lenbuf);
 
   /* If the mapping is available, try to search there instead of
      communicating with the nscd.  */
@@ -200,14 +202,10 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
 	  else
 	    {
 	      /* Allocate array to store lengths.  */
-	      if (lensize == 0)
-		{
-		  lensize = gr_resp.gr_mem_cnt * sizeof (uint32_t);
-		  len = (uint32_t *) alloca (lensize);
-		}
-	      else if (gr_resp.gr_mem_cnt * sizeof (uint32_t) > lensize)
-		len = extend_alloca (len, lensize,
-				     gr_resp.gr_mem_cnt * sizeof (uint32_t));
+	      if (!scratch_buffer_set_array_size
+		  (&lenbuf, gr_resp.gr_mem_cnt, sizeof (uint32_t)))
+		goto out_close;
+	      len = lenbuf.data;
 
 	      vec[0].iov_base = (void *) len;
 	      vec[0].iov_len = gr_resp.gr_mem_cnt * sizeof (uint32_t);
@@ -326,5 +324,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
 	goto retry;
     }
 
+  scratch_buffer_free (&lenbuf);
+
   return retval;
 }

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=c6ee40da8b7b285a644dc22b78d8e47d2bebfae6

commit c6ee40da8b7b285a644dc22b78d8e47d2bebfae6
Author: Florian Weimer <fweimer@redhat.com>
Date:   Wed Apr 8 20:56:35 2015 +0200

    getnameinfo: Use struct scratch_buffer instead of extend_alloca
    
    This patch adjusts the internal function nrl_domainname, too.

diff --git a/ChangeLog b/ChangeLog
index f9c5f68..93583af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@
 	grp/compat-initgroups.c.
 	* nis/nss_compat/compat-initgroups.c (_nss_compat_initgroups_dyn):
 	Rewrite to use struct scratch_buffer instead of extend_alloca.
+	* inet/getnameinfo.c (nrl_domainname, getnameinfo): Likewise.
 
 2015-04-08  Joseph Myers  <joseph@codesourcery.com>
 
diff --git a/inet/getnameinfo.c b/inet/getnameinfo.c
index ce54fe4..0126f20 100644
--- a/inet/getnameinfo.c
+++ b/inet/getnameinfo.c
@@ -35,7 +35,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 /* This software is Copyright 1996 by Craig Metz, All Rights Reserved.  */
 
-#include <alloca.h>
 #include <errno.h>
 #include <netdb.h>
 #include <stddef.h>
@@ -53,6 +52,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <sys/un.h>
 #include <sys/utsname.h>
 #include <bits/libc-lock.h>
+#include <scratch_buffer.h>
 
 #ifdef HAVE_LIBIDN
 # include <libidn/idna.h>
@@ -82,17 +82,21 @@ nrl_domainname (void)
 	{
 	  char *c;
 	  struct hostent *h, th;
-	  size_t tmpbuflen = 1024;
-	  char *tmpbuf = alloca (tmpbuflen);
 	  int herror;
+	  struct scratch_buffer tmpbuf;
 
+	  scratch_buffer_init (&tmpbuf);
 	  not_first = 1;
 
-	  while (__gethostbyname_r ("localhost", &th, tmpbuf, tmpbuflen, &h,
-				    &herror))
+	  while (__gethostbyname_r ("localhost", &th,
+				    tmpbuf.data, tmpbuf.length,
+				    &h, &herror))
 	    {
 	      if (herror == NETDB_INTERNAL && errno == ERANGE)
-		tmpbuf = extend_alloca (tmpbuf, tmpbuflen, 2 * tmpbuflen);
+		{
+		  if (!scratch_buffer_grow (&tmpbuf))
+		    goto done;
+		}
 	      else
 		break;
 	    }
@@ -103,22 +107,26 @@ nrl_domainname (void)
 	    {
 	      /* The name contains no domain information.  Use the name
 		 now to get more information.  */
-	      while (__gethostname (tmpbuf, tmpbuflen))
-		tmpbuf = extend_alloca (tmpbuf, tmpbuflen, 2 * tmpbuflen);
+	      while (__gethostname (tmpbuf.data, tmpbuf.length))
+		if (!scratch_buffer_grow (&tmpbuf))
+		  goto done;
 
-	      if ((c = strchr (tmpbuf, '.')))
+	      if ((c = strchr (tmpbuf.data, '.')))
 		domain = __strdup (++c);
 	      else
 		{
 		  /* We need to preserve the hostname.  */
-		  const char *hstname = strdupa (tmpbuf);
+		  const char *hstname = strdupa (tmpbuf.data);
 
-		  while (__gethostbyname_r (hstname, &th, tmpbuf, tmpbuflen,
+		  while (__gethostbyname_r (hstname, &th,
+					    tmpbuf.data, tmpbuf.length,
 					    &h, &herror))
 		    {
 		      if (herror == NETDB_INTERNAL && errno == ERANGE)
-			tmpbuf = extend_alloca (tmpbuf, tmpbuflen,
-						2 * tmpbuflen);
+			{
+			  if (!scratch_buffer_grow (&tmpbuf))
+			    goto done;
+			}
 		      else
 			break;
 		    }
@@ -133,12 +141,15 @@ nrl_domainname (void)
 
 		      while (__gethostbyaddr_r ((const char *) &in_addr,
 						sizeof (struct in_addr),
-						AF_INET, &th, tmpbuf,
-						tmpbuflen, &h, &herror))
+						AF_INET, &th,
+						tmpbuf.data, tmpbuf.length,
+						&h, &herror))
 			{
 			  if (herror == NETDB_INTERNAL && errno == ERANGE)
-			    tmpbuf = extend_alloca (tmpbuf, tmpbuflen,
-						    2 * tmpbuflen);
+			    {
+			      if (!scratch_buffer_grow (&tmpbuf))
+				goto done;
+			    }
 			  else
 			    break;
 			}
@@ -148,6 +159,8 @@ nrl_domainname (void)
 		    }
 		}
 	    }
+	done:
+	  scratch_buffer_free (&tmpbuf);
 	}
 
       __libc_lock_unlock (lock);
@@ -163,11 +176,12 @@ getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
 	     int flags)
 {
   int serrno = errno;
-  int tmpbuflen = 1024;
   int herrno;
-  char *tmpbuf = alloca (tmpbuflen);
   struct hostent th;
   int ok = 0;
+  struct scratch_buffer tmpbuf;
+
+  scratch_buffer_init (&tmpbuf);
 
   if (flags & ~(NI_NUMERICHOST|NI_NUMERICSERV|NI_NOFQDN|NI_NAMEREQD|NI_DGRAM
 #ifdef HAVE_LIBIDN
@@ -212,21 +226,35 @@ getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
 	      {
 		while (__gethostbyaddr_r ((const void *) &(((const struct sockaddr_in6 *) sa)->sin6_addr),
 					  sizeof(struct in6_addr),
-					  AF_INET6, &th, tmpbuf, tmpbuflen,
+					  AF_INET6, &th,
+					  tmpbuf.data, tmpbuf.length,
 					  &h, &herrno))
 		  if (herrno == NETDB_INTERNAL && errno == ERANGE)
-		    tmpbuf = extend_alloca (tmpbuf, tmpbuflen, 2 * tmpbuflen);
+		    {
+		      if (!scratch_buffer_grow (&tmpbuf))
+			{
+			  __set_h_errno (herrno);
+			  return EAI_MEMORY;
+			}
+		    }
 		  else
 		    break;
 	      }
 	    else
 	      {
 		while (__gethostbyaddr_r ((const void *) &(((const struct sockaddr_in *)sa)->sin_addr),
-					  sizeof(struct in_addr), AF_INET,
-					  &th, tmpbuf, tmpbuflen,
+					  sizeof(struct in_addr),
+					  AF_INET, &th,
+					  tmpbuf.data, tmpbuf.length,
 					  &h, &herrno))
 		  if (herrno == NETDB_INTERNAL && errno == ERANGE)
-		    tmpbuf = extend_alloca (tmpbuf, tmpbuflen, 2 * tmpbuflen);
+		    {
+		      if (!scratch_buffer_grow (&tmpbuf))
+			{
+			  __set_h_errno (herrno);
+			  return EAI_MEMORY;
+			}
+		    }
 		  else
 		    break;
 	      }
@@ -401,11 +429,14 @@ getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
 	    int e;
 	    while ((e = __getservbyport_r (((const struct sockaddr_in *) sa)->sin_port,
 					   ((flags & NI_DGRAM)
-					    ? "udp" : "tcp"),
-					   &ts, tmpbuf, tmpbuflen, &s)))
+					    ? "udp" : "tcp"), &ts,
+					   tmpbuf.data, tmpbuf.length, &s)))
 	      {
 		if (e == ERANGE)
-		  tmpbuf = extend_alloca (tmpbuf, tmpbuflen, 2 * tmpbuflen);
+		  {
+		    if (!scratch_buffer_grow (&tmpbuf))
+		      return EAI_MEMORY;
+		  }
 		else
 		  break;
 	      }

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=794a74af4da66ecde74d8e298e03b3b578a1ed33

commit 794a74af4da66ecde74d8e298e03b3b578a1ed33
Author: Florian Weimer <fweimer@redhat.com>
Date:   Wed Apr 8 20:55:02 2015 +0200

    _nss_compat_initgroups_dyn: Use struct scratch_buffer instead of extend_alloca

diff --git a/ChangeLog b/ChangeLog
index 3da105b..f9c5f68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,8 @@
 	scratch_buffer instead of extend_alloca.
 	* nscd/initgrcache.c: Include <scratch_buffer.h>, now needed by
 	grp/compat-initgroups.c.
+	* nis/nss_compat/compat-initgroups.c (_nss_compat_initgroups_dyn):
+	Rewrite to use struct scratch_buffer instead of extend_alloca.
 
 2015-04-08  Joseph Myers  <joseph@codesourcery.com>
 
diff --git a/nis/nss_compat/compat-initgroups.c b/nis/nss_compat/compat-initgroups.c
index 2f8ba72..eaff0f6 100644
--- a/nis/nss_compat/compat-initgroups.c
+++ b/nis/nss_compat/compat-initgroups.c
@@ -16,7 +16,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <alloca.h>
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -30,6 +29,7 @@
 #include <nsswitch.h>
 #include <bits/libc-lock.h>
 #include <kernel-features.h>
+#include <scratch_buffer.h>
 
 static service_user *ni;
 /* Type of the lookup function.  */
@@ -528,46 +528,31 @@ _nss_compat_initgroups_dyn (const char *user, gid_t group, long int *start,
 			    long int *size, gid_t **groupsp, long int limit,
 			    int *errnop)
 {
-  size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
-  char *tmpbuf;
   enum nss_status status;
   ent_t intern = { true, false, false, NULL, {NULL, 0, 0} };
-  bool use_malloc = false;
 
   status = internal_setgrent (&intern);
   if (status != NSS_STATUS_SUCCESS)
     return status;
 
-  tmpbuf = __alloca (buflen);
+  struct scratch_buffer tmpbuf;
+  scratch_buffer_init (&tmpbuf);
 
   do
     {
-      while ((status = internal_getgrent_r (&intern, tmpbuf, buflen,
+      while ((status = internal_getgrent_r (&intern, tmpbuf.data, tmpbuf.length,
 					    user, group, start, size,
 					    groupsp, limit, errnop))
 	     == NSS_STATUS_TRYAGAIN && *errnop == ERANGE)
-        if (__libc_use_alloca (buflen * 2))
-          tmpbuf = extend_alloca (tmpbuf, buflen, 2 * buflen);
-        else
-          {
-            buflen *= 2;
-            char *newbuf = realloc (use_malloc ? tmpbuf : NULL, buflen);
-            if (newbuf == NULL)
-              {
-                status = NSS_STATUS_TRYAGAIN;
-                goto done;
-              }
-            use_malloc = true;
-            tmpbuf = newbuf;
-          }
+        if (!scratch_buffer_grow (&tmpbuf))
+	    goto done;
     }
   while (status == NSS_STATUS_SUCCESS);
 
   status = NSS_STATUS_SUCCESS;
 
  done:
-  if (use_malloc)
-    free (tmpbuf);
+  scratch_buffer_free (&tmpbuf);
 
   internal_endgrent (&intern);
 

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=866ba63b312fd015e1585ee46943f57187e82868

commit 866ba63b312fd015e1585ee46943f57187e82868
Author: Florian Weimer <fweimer@redhat.com>
Date:   Wed Apr 8 20:51:34 2015 +0200

    grp: Rewrite to use struct scratch_buffer instead of extend_alloca
    
    grp/compat-initgroups.c is included from nscd/initgrcache.c, which is
    why the #include directive has to be added there as well.

diff --git a/ChangeLog b/ChangeLog
index 6bd6303..3da105b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,12 @@
 	* elf/pldd.c (main): Rewrite to use struct
 	scratch_buffer instead of extend_alloca.
 	* elf/pldd-xx.c (find_maps): Likewise.
+	* grp/initgroups.c: Include <scratch_buffer.h> instead of
+	<alloca.h>.
+	* grp/compat-initgroups.c (compat_call): Rewrite to use struct
+	scratch_buffer instead of extend_alloca.
+	* nscd/initgrcache.c: Include <scratch_buffer.h>, now needed by
+	grp/compat-initgroups.c.
 
 2015-04-08  Joseph Myers  <joseph@codesourcery.com>
 
diff --git a/grp/compat-initgroups.c b/grp/compat-initgroups.c
index ff10e24..3dd50d2 100644
--- a/grp/compat-initgroups.c
+++ b/grp/compat-initgroups.c
@@ -14,7 +14,6 @@ compat_call (service_user *nip, const char *user, gid_t group, long int *start,
 	     long int *size, gid_t **groupsp, long int limit, int *errnop)
 {
   struct group grpbuf;
-  size_t buflen = __sysconf (_SC_GETGR_R_SIZE_MAX);
   enum nss_status status;
   set_function setgrent_fct;
   get_function getgrent_fct;
@@ -35,30 +34,22 @@ compat_call (service_user *nip, const char *user, gid_t group, long int *start,
 
   endgrent_fct = __nss_lookup_function (nip, "endgrent");
 
-  char *tmpbuf = __alloca (buflen);
-  bool use_malloc = false;
+  struct scratch_buffer tmpbuf;
+  scratch_buffer_init (&tmpbuf);
   enum nss_status result = NSS_STATUS_SUCCESS;
 
   do
     {
       while ((status = DL_CALL_FCT (getgrent_fct,
-				     (&grpbuf, tmpbuf, buflen, errnop)),
+				     (&grpbuf, tmpbuf.data, tmpbuf.length,
+				      errnop)),
 	      status == NSS_STATUS_TRYAGAIN)
 	     && *errnop == ERANGE)
         {
-	  if (__libc_use_alloca (buflen * 2))
-	    tmpbuf = extend_alloca (tmpbuf, buflen, buflen * 2);
-	  else
+	  if (!scratch_buffer_grow (&tmpbuf))
 	    {
-	      buflen *= 2;
-	      char *newbuf = realloc (use_malloc ? tmpbuf : NULL, buflen);
-	      if (newbuf == NULL)
-		{
-		  result = NSS_STATUS_TRYAGAIN;
-		  goto done;
-		}
-	      use_malloc = true;
-	      tmpbuf = newbuf;
+	      result = NSS_STATUS_TRYAGAIN;
+	      goto done;
 	    }
         }
 
@@ -116,8 +107,7 @@ compat_call (service_user *nip, const char *user, gid_t group, long int *start,
   while (status == NSS_STATUS_SUCCESS);
 
  done:
-  if (use_malloc)
-    free (tmpbuf);
+  scratch_buffer_free (&tmpbuf);
 
   if (endgrent_fct)
     DL_CALL_FCT (endgrent_fct, ());
diff --git a/grp/initgroups.c b/grp/initgroups.c
index 4d083ac..14a8ab1 100644
--- a/grp/initgroups.c
+++ b/grp/initgroups.c
@@ -15,7 +15,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <alloca.h>
 #include <assert.h>
 #include <errno.h>
 #include <grp.h>
@@ -26,6 +25,7 @@
 #include <sys/param.h>
 #include <sys/types.h>
 #include <nsswitch.h>
+#include <scratch_buffer.h>
 
 #include "../nscd/nscd-client.h"
 #include "../nscd/nscd_proto.h"
diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c
index 7ba76be..e45d65c 100644
--- a/nscd/initgrcache.c
+++ b/nscd/initgrcache.c
@@ -24,6 +24,7 @@
 #include <time.h>
 #include <unistd.h>
 #include <sys/mman.h>
+#include <scratch_buffer.h>
 
 #include "dbg_log.h"
 #include "nscd.h"

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=7b8399f479fb9ebaf816a49246ea5c6354a0769e

commit 7b8399f479fb9ebaf816a49246ea5c6354a0769e
Author: Florian Weimer <fweimer@redhat.com>
Date:   Wed Apr 8 19:11:21 2015 +0200

    pldd: Use struct scratch_buffer instead of extend_alloca

diff --git a/ChangeLog b/ChangeLog
index 7f05d2e..6bd6303 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-04-08  Florian Weimer  <fweimer@redhat.com>
+
+	* elf/pldd.c (main): Rewrite to use struct
+	scratch_buffer instead of extend_alloca.
+	* elf/pldd-xx.c (find_maps): Likewise.
+
 2015-04-08  Joseph Myers  <joseph@codesourcery.com>
 
 	* math/auto-libm-test-in: Add more tests of cbrt.
diff --git a/elf/pldd-xx.c b/elf/pldd-xx.c
index d865739..2f19628 100644
--- a/elf/pldd-xx.c
+++ b/elf/pldd-xx.c
@@ -186,35 +186,43 @@ E(find_maps) (pid_t pid, void *auxv, size_t auxv_size)
   printf ("%lu:\t%s\n", (unsigned long int) pid, exe);
 
   /* Iterate over the list of objects and print the information.  */
-  size_t strsize = 256;
-  char *str = alloca (strsize);
+  struct scratch_buffer tmpbuf;
+  scratch_buffer_init (&tmpbuf);
+  int status = 0;
   do
     {
       struct E(link_map) m;
       if (pread64 (memfd, &m, sizeof (m), list) != sizeof (m))
 	{
 	  error (0, 0, gettext ("cannot read link map"));
-	  return EXIT_FAILURE;
+	  status = EXIT_FAILURE;
+	  goto out;
 	}
 
       EW(Addr) name_offset = m.l_name;
     again:
       while (1)
 	{
-	  ssize_t n = pread64 (memfd, str, strsize, name_offset);
+	  ssize_t n = pread64 (memfd, tmpbuf.data, tmpbuf.length, name_offset);
 	  if (n == -1)
 	    {
 	      error (0, 0, gettext ("cannot read object name"));
-	      return EXIT_FAILURE;
+	      status = EXIT_FAILURE;
+	      goto out;
 	    }
 
-	  if (memchr (str, '\0', n) != NULL)
+	  if (memchr (tmpbuf.data, '\0', n) != NULL)
 	    break;
 
-	  str = extend_alloca (str, strsize, strsize * 2);
+	  if (!scratch_buffer_grow (&tmpbuf))
+	    {
+	      error (0, 0, gettext ("cannot allocate buffer for object name"));
+	      status = EXIT_FAILURE;
+	      goto out;
+	    }
 	}
 
-      if (str[0] == '\0' && name_offset == m.l_name
+      if (((char *)tmpbuf.data)[0] == '\0' && name_offset == m.l_name
 	  && m.l_libname != 0)
 	{
 	  /* Try the l_libname element.  */
@@ -227,14 +235,16 @@ E(find_maps) (pid_t pid, void *auxv, size_t auxv_size)
 	}
 
       /* Skip over the executable.  */
-      if (str[0] != '\0')
-	printf ("%s\n", str);
+      if (((char *)tmpbuf.data)[0] != '\0')
+	printf ("%s\n", (char *)tmpbuf.data);
 
       list = m.l_next;
     }
   while (list != 0);
 
-  return 0;
+ out:
+  scratch_buffer_free (&tmpbuf);
+  return status;
 }
 
 
diff --git a/elf/pldd.c b/elf/pldd.c
index 9e1d822..2b86224 100644
--- a/elf/pldd.c
+++ b/elf/pldd.c
@@ -35,6 +35,7 @@
 #include <sys/ptrace.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
+#include <scratch_buffer.h>
 
 #include <ldsodefs.h>
 #include <version.h>
@@ -118,18 +119,25 @@ main (int argc, char *argv[])
   if (dfd == -1)
     error (EXIT_FAILURE, errno, gettext ("cannot open %s"), buf);
 
-  size_t exesize = 1024;
-#ifdef PATH_MAX
-  exesize = PATH_MAX;
-#endif
-  exe = alloca (exesize);
+  struct scratch_buffer exebuf;
+  scratch_buffer_init (&exebuf);
   ssize_t nexe;
-  while ((nexe = readlinkat (dfd, "exe", exe, exesize)) == exesize)
-    extend_alloca (exe, exesize, 2 * exesize);
+  while ((nexe = readlinkat (dfd, "exe",
+			     exebuf.data, exebuf.length)) == exebuf.length)
+    {
+      if (!scratch_buffer_grow (&exebuf))
+	{
+	  nexe = -1;
+	  break;
+	}
+    }
   if (nexe == -1)
     exe = (char *) "<program name undetermined>";
   else
-    exe[nexe] = '\0';
+    {
+      exe = exebuf.data;
+      exe[nexe] = '\0';
+    }
 
   /* Stop all threads since otherwise the list of loaded modules might
      change while we are reading it.  */

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                          |   16 +++++++
 elf/pldd-xx.c                      |   32 +++++++++-----
 elf/pldd.c                         |   24 +++++++---
 grp/compat-initgroups.c            |   26 +++--------
 grp/initgroups.c                   |    2 +-
 inet/getnameinfo.c                 |   85 ++++++++++++++++++++++++-----------
 nis/nss_compat/compat-initgroups.c |   29 +++---------
 nscd/initgrcache.c                 |    1 +
 nscd/nscd_getgr_r.c                |   18 ++++----
 9 files changed, 137 insertions(+), 96 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]