From 5d7e00a109360adf28c5a292ab80e7f1a1f2c092 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Fri, 8 Jan 2021 22:31:16 +0000 Subject: [PATCH] cd: validate $OLDPWD (Solaris patch 185-Bug17714341) This change was pulled in from: https://raw.githubusercontent.com/oracle/solaris-userland/master/components/ksh93/patches/185-Bug17714341.patch No public information about the reasons for this change is available, but it seems reasonable to trust that the Solaris people found a legitimate need for it. src/cmd/ksh93/bltins/cd_pwd.c: b_cd(): - When determining the old PWD before 'cd', do not trust shp->pwd but get and validate the current PWD using path_pwd(). --- src/cmd/ksh93/bltins/cd_pwd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/ksh93/bltins/cd_pwd.c b/src/cmd/ksh93/bltins/cd_pwd.c index eebd5078da70..753aa19618b8 100644 --- a/src/cmd/ksh93/bltins/cd_pwd.c +++ b/src/cmd/ksh93/bltins/cd_pwd.c @@ -80,7 +80,7 @@ int b_cd(int argc, char *argv[],Shbltin_t *context) dir = argv[0]; if(error_info.errors>0 || argc >2) errormsg(SH_DICT,ERROR_usage(2),"%s",optusage((char*)0)); - oldpwd = (char*)shp->pwd; + oldpwd = path_pwd(shp,0); opwdnod = (shp->subshell?sh_assignok(OLDPWDNOD,1):OLDPWDNOD); pwdnod = (shp->subshell?sh_assignok(PWDNOD,1):PWDNOD); if(argc==2)