60 lines
1.5 KiB
Diff
60 lines
1.5 KiB
Diff
From 19c75aec6843b827fa7ef3f39174090ee7f8ac18 Mon Sep 17 00:00:00 2001
|
|
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
|
|
Date: Thu, 22 Jan 2015 20:20:15 +0000
|
|
Subject: [PATCH] 34331: better handling of NULL in cd.
|
|
|
|
Problem was return from symbolic link expander in weird cases
|
|
where there file system isn't behaving itself properly.
|
|
|
|
Upstream-commit: 12b813b5895cae579e403dafe43878868f27fe0f
|
|
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
|
|
---
|
|
Src/builtin.c | 8 +++++---
|
|
Src/utils.c | 11 +++++++----
|
|
2 files changed, 12 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/Src/builtin.c b/Src/builtin.c
|
|
index 2118835..489ca23 100644
|
|
--- a/Src/builtin.c
|
|
+++ b/Src/builtin.c
|
|
@@ -1156,9 +1156,11 @@ cd_new_pwd(int func, LinkNode dir, int quiet)
|
|
zsfree(getlinknode(dirstack));
|
|
|
|
if (chasinglinks) {
|
|
- s = new_pwd;
|
|
- new_pwd = findpwd(s);
|
|
- zsfree(s);
|
|
+ s = findpwd(new_pwd);
|
|
+ if (s) {
|
|
+ zsfree(new_pwd);
|
|
+ new_pwd = s;
|
|
+ }
|
|
}
|
|
if (isset(PUSHDIGNOREDUPS)) {
|
|
LinkNode n;
|
|
diff --git a/Src/utils.c b/Src/utils.c
|
|
index e6eb8e6..80396a2 100644
|
|
--- a/Src/utils.c
|
|
+++ b/Src/utils.c
|
|
@@ -1049,10 +1049,13 @@ getnameddir(char *name)
|
|
if ((pw = getpwnam(name))) {
|
|
char *dir = isset(CHASELINKS) ? xsymlink(pw->pw_dir)
|
|
: ztrdup(pw->pw_dir);
|
|
- adduserdir(name, dir, ND_USERNAME, 1);
|
|
- str = dupstring(dir);
|
|
- zsfree(dir);
|
|
- return str;
|
|
+ if (dir) {
|
|
+ adduserdir(name, dir, ND_USERNAME, 1);
|
|
+ str = dupstring(dir);
|
|
+ zsfree(dir);
|
|
+ return str;
|
|
+ } else
|
|
+ return ztrdup(pw->pw_dir);
|
|
}
|
|
}
|
|
#endif /* HAVE_GETPWNAM */
|
|
--
|
|
2.1.0
|
|
|