aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-08-20 18:07:28 +0000
committerUlrich Drepper <drepper@redhat.com>1999-08-20 18:07:28 +0000
commitbe7d999a0931203c5541714a255635459ee6dde2 (patch)
treedbc64a1ec52528fb7c81dc47039a31235e1c4952
parentf95a00152abfa60e3f825d0d29970421a618286d (diff)
downloadglibc-be7d999a0931203c5541714a255635459ee6dde2.tar
glibc-be7d999a0931203c5541714a255635459ee6dde2.tar.gz
glibc-be7d999a0931203c5541714a255635459ee6dde2.tar.bz2
glibc-be7d999a0931203c5541714a255635459ee6dde2.zip
Update.
* sysdeps/unix/sysv/linux/getcwd.c: Allocate buffer large enough not only if size == 0, but also for size < 0. * sysdeps/posix/getcwd.c: Likewise. [PR libc/1269]
-rw-r--r--ChangeLog5
-rw-r--r--sysdeps/posix/getcwd.c4
-rw-r--r--sysdeps/unix/sysv/linux/getcwd.c6
3 files changed, 8 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 97fdc6e370..d036936303 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,8 @@
1999-08-20 Ulrich Drepper <drepper@cygnus.com>
- * sysdeps/posix/getcwd.c: Allocate buffer large enough not only if
- size == 0, but also for size < 0 [PR libc/1269].
+ * sysdeps/unix/sysv/linux/getcwd.c: Allocate buffer large enough
+ not only if size == 0, but also for size < 0.
+ * sysdeps/posix/getcwd.c: Likewise. [PR libc/1269]
* posix/execvp.c (execvp): Allocate array name of correct size.
Optimize inner loop. Use execve directly, not execv.
diff --git a/sysdeps/posix/getcwd.c b/sysdeps/posix/getcwd.c
index 886a0ba827..e79598b045 100644
--- a/sysdeps/posix/getcwd.c
+++ b/sysdeps/posix/getcwd.c
@@ -226,7 +226,7 @@ __getcwd (buf, size)
int prev_errno = errno;
size_t allocated = size;
- if (size == 0)
+ if (size <= 0)
{
if (buf != NULL)
{
@@ -363,7 +363,7 @@ __getcwd (buf, size)
if ((size_t) (pathp - path) <= namlen)
{
- if (size != 0)
+ if (size > 0)
{
(void) __closedir (dirstream);
__set_errno (ERANGE);
diff --git a/sysdeps/unix/sysv/linux/getcwd.c b/sysdeps/unix/sysv/linux/getcwd.c
index cc7b987f9b..223cd310b8 100644
--- a/sysdeps/unix/sysv/linux/getcwd.c
+++ b/sysdeps/unix/sysv/linux/getcwd.c
@@ -72,7 +72,7 @@ __getcwd (char *buf, size_t size)
if (no_syscall_getcwd && !have_new_dcache)
return generic_getcwd (buf, size);
- if (size == 0)
+ if (size <= 0)
{
if (buf != NULL)
{
@@ -179,7 +179,7 @@ __getcwd (char *buf, size_t size)
__set_errno (save_errno);
/* Don't put restrictions on the length of the path unless the user does. */
- if (size == 0)
+ if (size <= 0)
{
free (path);
path = NULL;
@@ -187,7 +187,7 @@ __getcwd (char *buf, size_t size)
result = generic_getcwd (path, size);
- if (result == NULL && buf == NULL && size != 0)
+ if (result == NULL && buf == NULL && size > 0)
free (path);
return result;