diff options
author | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2015-01-22 20:20:15 +0000 |
---|---|---|
committer | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2015-01-22 20:20:15 +0000 |
commit | 12b813b5895cae579e403dafe43878868f27fe0f (patch) | |
tree | aafceebff5feeaa2f76b0e7f59dd1e479464c7ab | |
parent | 99f42d8ce022645dfc38b8e06d25ab281e995cf9 (diff) | |
download | zsh-12b813b5895cae579e403dafe43878868f27fe0f.tar.gz zsh-12b813b5895cae579e403dafe43878868f27fe0f.tar.xz zsh-12b813b5895cae579e403dafe43878868f27fe0f.zip |
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.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Src/builtin.c | 8 | ||||
-rw-r--r-- | Src/utils.c | 11 |
3 files changed, 17 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog index 4b01b2ac3..9636f5c67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-22 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * 34331: Src/builtin.c, Src/utils.c: don't trip over + NULL pointer in cd in rare cases where file system goes AWOL. + 2015-01-22 Barton E. Schaefer <schaefer@zsh.org> * 34344: Test/V07pcre.ztst: fix 34338, builtins need loading too diff --git a/Src/builtin.c b/Src/builtin.c index 1818941b2..08be1acdd 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 4561b5e9a..cf18f1240 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -1108,10 +1108,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 */ |