mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-09-28 06:49:49 +02:00
41284: Fix NULL dereference in cd.
This happened in sh compatiblity mode if HOME was not set and cd was used with no argument.
This commit is contained in:
parent
d5c22d356b
commit
eb783754bd
@ -1,3 +1,8 @@
|
||||
2017-06-13 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* 41284: Src/builtin.c, Test/B01cd.ztst: fix null dereference on
|
||||
cd with no argument if HOME is not set.
|
||||
|
||||
2017-06-12 Peter Stephenson <p.stephenson@samsung.com>
|
||||
|
||||
* 41244: Doc/Zsh/builtins.yo, Src/Modules/zftp.c,
|
||||
|
@ -880,8 +880,13 @@ cd_get_dest(char *nam, char **argv, int hard, int func)
|
||||
dir = nextnode(firstnode(dirstack));
|
||||
if (dir)
|
||||
zinsertlinknode(dirstack, dir, getlinknode(dirstack));
|
||||
else if (func != BIN_POPD)
|
||||
else if (func != BIN_POPD) {
|
||||
if (!home) {
|
||||
zwarnnam(nam, "HOME not set");
|
||||
return NULL;
|
||||
}
|
||||
zpushnode(dirstack, ztrdup(home));
|
||||
}
|
||||
} else if (!argv[1]) {
|
||||
int dd;
|
||||
char *end;
|
||||
@ -936,6 +941,10 @@ cd_get_dest(char *nam, char **argv, int hard, int func)
|
||||
if (!dir) {
|
||||
dir = firstnode(dirstack);
|
||||
}
|
||||
if (!dir || !getdata(dir)) {
|
||||
DPUTS(1, "Directory not set, not detected early enough");
|
||||
return NULL;
|
||||
}
|
||||
if (!(dest = cd_do_chdir(nam, getdata(dir), hard))) {
|
||||
if (!target)
|
||||
zsfree(getlinknode(dirstack));
|
||||
|
@ -137,6 +137,10 @@ F:something is broken. But you already knew that.
|
||||
0:
|
||||
?(eval):cd:3: not a directory: link_to_nonexistent
|
||||
|
||||
(unset HOME; ARGV0=sh $ZTST_testdir/../Src/zsh -c cd)
|
||||
1:Implicit cd with unset HOME.
|
||||
?zsh:cd:1: HOME not set
|
||||
|
||||
%clean
|
||||
# This optional section cleans up after the test, if necessary,
|
||||
# e.g. killing processes etc. This is in addition to the removal of *.tmp
|
||||
|
Loading…
Reference in New Issue
Block a user