[klibc] 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@altlinux.ru>
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 @@
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