diff options
author | maximilian attems <max@stro.at> | 2010-04-02 07:18:50 +0200 |
---|---|---|
committer | maximilian attems <max@stro.at> | 2010-04-02 07:30:37 +0200 |
commit | dd99829df93e4666d4047548e1c9b085b2dd6b15 (patch) | |
tree | 8f5609fab46c35102706cb7d5efff11b6e608908 | |
parent | 4237d17e660d14dfd09b88cedca944ed579bd019 (diff) | |
download | klibc-dd99829df93e4666d4047548e1c9b085b2dd6b15.tar.gz |
[klibc] dash: cd fix getpwd
On review of klibc dash changes:
"Hmm, this breaks the non-glibc case. You're now returning a pointer to
a string on the stack which is illegal." Herbert Xu
Use upstream dash way.
Signed-off-by: maximilian attems <max@stro.at>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | usr/dash/cd.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/usr/dash/cd.c b/usr/dash/cd.c index 8a23110e62c81..ba9a1bc00f305 100644 --- a/usr/dash/cd.c +++ b/usr/dash/cd.c @@ -253,12 +253,13 @@ getpwd() { #ifdef __GLIBC__ char *dir = getcwd(0, 0); + if (dir) + return dir; #else char buf[PATH_MAX]; - char *dir = getcwd(buf, sizeof(buf)); + if(getcwd(buf, sizeof(buf))) + return savestr(buf); #endif - if (dir) - return dir; sh_warnx("getcwd() failed: %s", strerror(errno)); return nullstr; } |