Sergey Vlasov
2007-Jan-27  16:55 UTC
[klibc] [PATCH] dash: Fix "pwd -P" breakage due to getcwd(0, 0) usage
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
Seemingly Similar Threads
- [PATCH] dash: cd fix getpwd
- [klibc:update-dash] dash: Fix some cosmetic differences from upstream dash
- [klibc:update-dash] dash: Fix some cosmetic differences from upstream dash
- [PATCH] umount: Add -l option for lazy unmount
- [PATCH 1/2] chain.c32: fix bounce buffer handling
