DASH Shell discussions
 help / color / mirror / Atom feed
* [PATCH] [klibc] dash: cd fix getpwd
@ 2010-04-02  5:26 y
  0 siblings, 0 replies; 2+ messages in thread
From: y @ 2010-04-02  5:26 UTC (permalink / raw)
  To: klibc; +Cc: H. Peter Anvin, dash, Herbert Xu, maximilian attems

From: maximilian attems <max@stro.at>

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>
---
 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 8a23110..ba9a1bc 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;
 }
-- 
1.7.0.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] [klibc] dash: cd fix getpwd
@ 2010-04-02  5:30 maximilian attems
  0 siblings, 0 replies; 2+ messages in thread
From: maximilian attems @ 2010-04-02  5:30 UTC (permalink / raw)
  To: klibc; +Cc: H. Peter Anvin, dash, Herbert Xu, maximilian attems

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>
---
sorry for resend, mesed up previous sent.

 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 8a23110..ba9a1bc 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;
 }
-- 
1.7.0.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-02  5:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-02  5:30 [PATCH] [klibc] dash: cd fix getpwd maximilian attems
  -- strict thread matches above, loose matches on Subject: below --
2010-04-02  5:26 y

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox