aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-07-13 17:37:44 +0000
committerUlrich Drepper <drepper@redhat.com>2000-07-13 17:37:44 +0000
commit9cd865e0ce0563d875b818d6d8e7032dc6d2817f (patch)
tree3daecabcef01e17a004ef5ca8754511e783dc257
parent964b082efd3296424aa37613136d7a22efd43e69 (diff)
downloadglibc-9cd865e0ce0563d875b818d6d8e7032dc6d2817f.zip
glibc-9cd865e0ce0563d875b818d6d8e7032dc6d2817f.tar.gz
glibc-9cd865e0ce0563d875b818d6d8e7032dc6d2817f.tar.bz2
Update.
2000-07-13 Andreas Jaeger <aj@suse.de> * sysdeps/unix/sysv/linux/getcwd.c (__getcwd): Correctly handle getcwd (NULL, size) with size > 0. Fixes PR libc/1788, reported by John Buddery <jvb@cyberscience.com>. 2000-07-13 Andreas Jaeger <aj@suse.de> * posix/Makefile: Remove build rules for libposix.
-rw-r--r--ChangeLog11
-rw-r--r--sysdeps/unix/sysv/linux/getcwd.c10
2 files changed, 17 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 057435a..c69ec09 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2000-07-13 Andreas Jaeger <aj@suse.de>
+
+ * sysdeps/unix/sysv/linux/getcwd.c (__getcwd): Correctly handle
+ getcwd (NULL, size) with size > 0.
+ Fixes PR libc/1788, reported by John Buddery
+ <jvb@cyberscience.com>.
+
+2000-07-13 Andreas Jaeger <aj@suse.de>
+
+ * posix/Makefile: Remove build rules for libposix.
+
2000-07-13 Andreas Schwab <schwab@suse.de>
* sysdeps/generic/glob.c (glob): Fix memory leak.
diff --git a/sysdeps/unix/sysv/linux/getcwd.c b/sysdeps/unix/sysv/linux/getcwd.c
index 6c68955..4178416 100644
--- a/sysdeps/unix/sysv/linux/getcwd.c
+++ b/sysdeps/unix/sysv/linux/getcwd.c
@@ -103,7 +103,7 @@ __getcwd (char *buf, size_t size)
retval = INLINE_SYSCALL (getcwd, 2, CHECK_STRING (path), alloc_size);
if (retval >= 0)
{
- if (buf == NULL)
+ if (buf == NULL && size == 0)
{
buf = realloc (path, (size_t) retval);
if (buf == NULL)
@@ -115,8 +115,9 @@ __getcwd (char *buf, size_t size)
# if __ASSUME_GETCWD_SYSCALL
/* It should never happen that the `getcwd' syscall failed because
- the buffer is too small if we allocated the buffer outself. */
- assert (errno != ERANGE || buf != NULL);
+ the buffer is too small if we allocated the buffer outselves
+ large enough. */
+ assert (errno != ERANGE || buf != NULL || size != 0);
if (buf == NULL)
free (path);
@@ -153,8 +154,9 @@ __getcwd (char *buf, size_t size)
}
path[n] = '\0';
- if (buf == NULL)
+ if (buf == NULL && size == 0)
{
+ /* Ensure that the buffer is only as large as necessary. */
buf = realloc (path, (size_t) n + 1);
if (buf == NULL)
/* `relloc' failed but we still have the original string. */