[klibc] [PATCH] dash: Fix "pwd -P" breakage due to getcwd(0, 0) usage

Sergey Vlasov vsu at altlinux.ru
Sat Jan 27 08:55:32 PST 2007


The getpwd() function in dash assumed than getcwd(0, 0) will
allocate the buffer dynamically using malloc(); however, this
glibc extension is not implemented by klibc.  Make getpwd() use a
temporary buffer and invoke savestr() itself instead of relying on
a nonstandard extension.

Signed-off-by: Sergey Vlasov <vsu at altlinux.ru>
---
 Alternatively, you may pull from the following git repo and branch:

    git://git.altlinux.org/people/vsu/packages/klibc.git upstream-fixes

 (also available over http: and rsync:, but the repo is fully packed).

 usr/dash/cd.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/usr/dash/cd.c b/usr/dash/cd.c
index 1849c69..567393f 100644
--- a/usr/dash/cd.c
+++ b/usr/dash/cd.c
@@ -251,8 +251,9 @@ inline
 STATIC char *
 getpwd()
 {
-	char *dir = getcwd(0, 0);
-	return dir ? dir : nullstr;
+	char buf[PATH_MAX];
+	char *dir = getcwd(buf, sizeof(buf));
+	return dir ? savestr(dir) : nullstr;
 }
 
 int
-- 
1.5.0.rc1.gbcae



More information about the klibc mailing list