about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-07-07 12:30:38 +0000
committerUlrich Drepper <drepper@redhat.com>1999-07-07 12:30:38 +0000
commitc9cddf51e757d8e59f0d5ead82a9d2414d61e9be (patch)
treedc062319ee06c22ea0b2c3dd7316ff8d4f42e6ee
parentd7807bfa57f8d164e86816e030da4aa601affd89 (diff)
downloadglibc-c9cddf51e757d8e59f0d5ead82a9d2414d61e9be.tar.gz
glibc-c9cddf51e757d8e59f0d5ead82a9d2414d61e9be.tar.xz
glibc-c9cddf51e757d8e59f0d5ead82a9d2414d61e9be.zip
Update.
1999-07-07  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/posix/getcwd.c: When resizing buffer make sure new size
	is large enough.
-rw-r--r--ChangeLog5
-rw-r--r--sysdeps/posix/getcwd.c6
2 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index f73f31eca2..b9216e26c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+1999-07-07  Ulrich Drepper  <drepper@cygnus.com>
+
+	* sysdeps/posix/getcwd.c: When resizing buffer make sure new size
+	is large enough.
+
 1999-07-07  Andreas Schwab  <schwab@suse.de>
 
 	* sysdeps/unix/sysv/linux/getpt.c: Check that /dev/pts is mounted.
diff --git a/sysdeps/posix/getcwd.c b/sysdeps/posix/getcwd.c
index fe094b5a35..950ae613e7 100644
--- a/sysdeps/posix/getcwd.c
+++ b/sysdeps/posix/getcwd.c
@@ -135,6 +135,10 @@ extern void free ();
 # define memmove memcpy
 #endif	/* Not ANSI_STRING.  */
 
+#ifndef MAX
+# define MAX(a, b) ((a) < (b) ? (b) : (a))
+#endif
+
 #ifdef _LIBC
 # ifndef mempcpy
 #  define mempcpy __mempcpy
@@ -368,7 +372,7 @@ __getcwd (buf, size)
 		{
 		  char *tmp;
 
-		  size *= 2;
+		  size = 2 * MAX (size, namlen);
 		  tmp = realloc (path, size);
 		  if (tmp == NULL)
 		    {