DASH Shell discussions
 help / color / mirror / Atom feed
From: maximilian attems <max@stro.at>
To: klibc@zytor.com
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	dash@vger.kernel.org, Herbert Xu <herbert@gondor.apana.org.au>,
	maximilian attems <max@stro.at>
Subject: [PATCH] [klibc] dash: cd fix getpwd
Date: Fri,  2 Apr 2010 07:30:09 +0200	[thread overview]
Message-ID: <1270186209-14582-1-git-send-email-max@stro.at> (raw)

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


             reply	other threads:[~2010-04-02  5:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-02  5:30 maximilian attems [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-04-02  5:26 [PATCH] [klibc] dash: cd fix getpwd y

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1270186209-14582-1-git-send-email-max@stro.at \
    --to=max@stro.at \
    --cc=dash@vger.kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=hpa@zytor.com \
    --cc=klibc@zytor.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox