Skip to contentSkip to conversation

dash: cd fix getpwd

PATCH New maximilian attems 1 participant 1 message Apr 2, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
sorry for resend, mesed up previous sent.

 usr/dash/cd.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
usr/dash/cd.c +4 -3
index 8a23110..ba9a1bc 100644
@@ -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;
 }
Signature · 1 line
1.7.0.3