From 434de2bfe0a74d4efc578e4da623d4ba783e9d8a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 5 Jan 2008 05:32:09 +0000 Subject: michael_d in #1849 writes: The getcwd() implementation in the absence of a getcwd syscall has an off-by-one allocation bug. As a result, sometimes the returned string has garbage at the end. --- libc/sysdeps/linux/common/getcwd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libc/sysdeps') diff --git a/libc/sysdeps/linux/common/getcwd.c b/libc/sysdeps/linux/common/getcwd.c index 165ea317e..d52792994 100644 --- a/libc/sysdeps/linux/common/getcwd.c +++ b/libc/sysdeps/linux/common/getcwd.c @@ -165,7 +165,7 @@ int __syscall_getcwd(char * buf, unsigned long size) cwd = recurser(buf, size, st.st_dev, st.st_ino); if (cwd) { - len = strlen(buf); + len = strlen(buf) + 1; __set_errno(olderrno); } return len; -- cgit v1.2.3